Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

No suitable driver

2 posts in JDBC Connect (product renamed to JConnect) Last posting was on 1997-07-10 12:36:50.0Z
Don Blair Posted on 1997-07-09 18:23:28.0Z
Message-ID: <33C3D720.3FDD@sybase.com>
Date: Wed, 09 Jul 1997 14:23:28 -0400
From: Don Blair <dblair@sybase.com>
Reply-To: dblair@sybase.com
Organization: Powersoft
X-Mailer: Mozilla 3.0 (Win95; I)
MIME-Version: 1.0
CC: dblair
Subject: No suitable driver
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 18
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:570
Article PK: 252322

I am able to connect to jConnect successfully as
long as I put both of the following commands in the same
class:

Class.forName("com.sybase.jdbc.SybDriver");
_conn = DriverManager.getConnection(url, _props);

However, I get the following error if they reside
in different classe:

No suitable driver

I looked at the DriverManager source, and I suspect
it's because different classes have different security
contexts, and Java doesn't allow you to connect to
a driver that was loaded from a different security
context.

Is there a way around this restriction? Can I put
these commands in different classes? How about
different *packages*?

Don


Lance Andersen Posted on 1997-07-10 12:36:50.0Z
Message-ID: <33C4D762.58DB@sybase.com>
Date: Thu, 10 Jul 1997 08:36:50 -0400
From: Lance Andersen <lancea@sybase.com>
X-Mailer: Mozilla 3.01Gold (X11; I; SunOS 5.5.1 sun4m)
MIME-Version: 1.0
To: dblair@sybase.com
Subject: Re: No suitable driver
References: <33C3D720.3FDD@sybase.com>
Content-Type: multipart/mixed; boundary="------------42D516754B73"
Newsgroups: sybase.public.jdbcconnect
Lines: 106
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:568
Article PK: 252320

Don,

I have attached two files:

InitDriver.java
LoadDriver.java

InitDriver has one method which when invoked does a
Class.forName().

LoadDriver invokes this method and then makes a connection
to a sybase sql server.


Regards,

-Lance

Don Blair wrote:
>
> I am able to connect to jConnect successfully as
> long as I put both of the following commands in the same
> class:
>
> Class.forName("com.sybase.jdbc.SybDriver");
> _conn = DriverManager.getConnection(url, _props);
>
> However, I get the following error if they reside
> in different classe:
>
> No suitable driver
>
> I looked at the DriverManager source, and I suspect
> it's because different classes have different security
> contexts, and Java doesn't allow you to connect to
> a driver that was loaded from a different security
> context.
>
> Is there a way around this restriction? Can I put
> these commands in different classes? How about
> different *packages*?
>
> Don

--
===============================================================================
Lance J. Andersen Email: lancea@sybase.com
Sybase Technical Support Phone:(617) 564-6336
77 South Bedford Street Fax: (617) 564-6148
Burlington, MA 01803

The Dark Knight Returns!!! Let's Go Penguins!!!
===============================================================================

import java.io.*;
import java.sql.*;
import com.sybase.utils.Debug;
import java.util.*;

public class InitDriver
{

static public void setupDriver()
{
try
{

Class.forName("com.sybase.jdbc.SybDriver");


}
catch (Exception e)
{

System.out.println("Unexpected exception : " + e.toString());
System.out.println("\nThis error usually indicates that " +
"your Java CLASSPATH environment has not been set properly.");

e.printStackTrace();
System.exit(1);

}

}
}

import java.io.*;
import java.sql.*;
import java.sql.Connection;
import com.sybase.utils.Debug;
import java.util.*;

public class LoadDriver
{
static String url = "jdbc:sybase:Tds:alder:6689/pubs2";
static String _user= "sa";
static String _password = "";

public static void main(String args[])
{
try
{



InitDriver.setupDriver();

System.out.println("Registered JDBC Drivers:");
for(Enumeration edrivers = DriverManager.getDrivers();
edrivers.hasMoreElements();)
{
System.out.println(edrivers.nextElement());
}
Properties props = new Properties();
props.put("user", _user);
props.put("password", _password);

Connection con = DriverManager.getConnection(url, props);
System.out.println("Connected successfully");
con.close();

}
catch (SQLException sqe)
{
String sqlstate = sqe.getSQLState();
String message = sqe.toString();
System.out.println("Unexpected exception: " + sqlstate);

sqe.printStackTrace();
System.exit(1);

}
catch (Exception e)
{

System.out.println("Unexpected exception : " + e.toString());
System.out.println("\nThis error usually indicates that " +
"your Java CLASSPATH environment has not been set properly.");

e.printStackTrace();
System.exit(1);

}

}
}