Deepa Remesh wrote:
>On 9/21/05, Kathey Marsden <[EMAIL PROTECTED]> wrote:
>
>
>
>> The alternate
>>method is to go back to expecting the client itself to reject any
>>unacceptable urls.
>>
>>
>
>Since network server gives NPE with certain URLs, I think this has to
>be solved on the server side.
>
>
>
Yes, I suppose you are right that it is better not to make it incumbent
on the client to reject improperly formated database names which cause
the driver to reject the url. As an aside, I wonder, what makes a
databaseName be rejected by the embedded driver and why. The urls
below return null from connect but true from acceptsUrl? Shoudn't the
two match? I kind of think connect should throw an exception instead of
returning null for these urls.
jdbc:derby:"C:/dbs/mydb";create=true
jdbc:derby:!C:/dbs/mydb ~;create=true
>1. Network server checks for null connections returned by
>InternalDriver and throws a specific exception. It sends back RDBAFLRM
>and SQLCARD with this exception.
>
>//In org.apache.derby.impl.drda.Database.makeConnection(Properties)
>if(conn == null){
> throw new SQLException("No suitable driver","08001");
>}
>
>
>
I spoke with Deepa about this briefly. It might work to return RDBAFLRM
with an SQLCARD that contains an null SQLException for the case where
connect returns null. She is investigating.
>2. ClientDriver.connect checks for this exception and returns null.
>
> try{
> conn =
>new
>org.apache.derby.client.net.NetConnection((org.apache.derby.client.net.NetLogWriter)
> dncLogWriter,
> java.sql.DriverManager.getLoginTimeout(),
> server,
>0 port,
> database,
> augmentedProperties);
> }
> catch(java.sql.SQLException e){
> if(e.getMessage().indexOf("No suitable driver") != -1){
> //No suitable driver exception means a null connection
> was
> //returned to Network server by InternalDriver
> conn = null;
> }
> else
> throw e;
> }
>
> return conn;
>
>
>
>
If we do have this SQLException, client should check for the SQLState
instead of the message and have a constant for the SQLState.