Methods Summary |
---|
public boolean | acceptsURL(java.lang.String url)Returns true if the driver thinks that it can open a connection
to the given URL. In this case, true is returned if and only if
the subprotocol is 'msql'.
if( url.length() < 10 ) {
return false;
}
else {
return url.substring(5,9).equals("msql");
}
|
public java.sql.Connection | connect(java.lang.String url, java.util.Properties p)Takes a look at the given URL to see if it is meant for this
driver. If not, simply return null. If it is, then go ahead and
connect to the database. For the mSQL implementation of JDBC, it
looks for URL's in the form of
jdbc:msql://[host_addr]:[port]/[db_name]
String host, database, orig = url;
int i, port;
if( url.startsWith("jdbc:") ) {
if( url.length() < 6 ) {
return null;
}
url = url.substring(5);
}
if( !url.startsWith("msql://") ) {
return null;
}
if( url.length() < 8 ) {
return null;
}
url = url.substring(7);
i = url.indexOf(':");
if( i == -1 ) {
port = 1114;
i = url.indexOf('/");
if( i == -1 ) {
throw new SQLException("Invalid mSQL URL: " + orig);
}
if( url.length() < i+1 ) {
throw new SQLException("Invalid mSQL URL: " + orig);
}
host = url.substring(0, i);
database = url.substring(i+1);
}
else {
host = url.substring(0, i);
if( url.length() < i+1 ) {
throw new SQLException("Invalid mSQL URL: " + orig);
}
url = url.substring(i+1);
i = url.indexOf('/");
if( i == -1 ) {
throw new SQLException("Invalid mSQL URL: " + orig);
}
if( url.length() < i+1 ) {
throw new SQLException("Invalid mSQL URL: " + orig);
}
try {
port = Integer.parseInt(url.substring(0, i));
}
catch( NumberFormatException e ) {
throw new SQLException("Invalid port number: " +
url.substring(0, i));
}
database = url.substring(i+1);
}
return new MsqlConnection(host, port, database, p);
|
public int | getMajorVersion()Gives the major version for this driver as required by the JDBC
specification.
return 1;
|
public int | getMinorVersion()Gives the minor version for this driver as required by the JDBC
specification.
return 0;
|
public java.sql.DriverPropertyInfo[] | getPropertyInfo(java.lang.String url, java.util.Properties info)The getPropertyInfo method is intended to allow a generic GUI tool
to discover what properties it should prompt a human for in order to
get enough information to connect to a database. Note that depending
on the values the human has supplied so far, additional values
may become necessary, so it may be necessary to iterate though
several calls to getPropertyInfo.
return new DriverPropertyInfo[0];
|
public boolean | jdbcCompliant()Returns information noting the fact that the mSQL database is not
SQL-92 and thus cannot support a JDBC compliant implementation.
return false;
|