RE: Class Not Found Exception
- From: "David" <David@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 8 Feb 2006 12:41:29 -0800
Nevermind...
Colons... semicolons...
I was swept up in a new development environment that I missed a syntax error
(I had placed a colon between the server port and the database name instead
of a semicolon...)
"David" wrote:
Thanks for replying....
Okay... I've tweaked the classpath (I'm working in Eclipse), and am now
getting past the class.forname statement. However, I am getting a
SQLException error at the DriverManager.getconnection statement. "The error
is Unable to connect. Invalid URL". Would I be getting this because of the
URL defined in the new instance of the class, or because of the path defined
in the sqlserver connection variable? I've tried tweaking both, but both seem
to be valid.
thanks again for your help.
"Evan T. Basalik (MSFT)" wrote:
If you are using the SQL Server 2000 version of the driver, you will need:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
and
CLASSPATH=.;C:\JDBC\DDSP3\lib\msbase.jar;C:\JDBC\DDSP3\lib\mssqlserver.jar;C:\JDBC\DDSP3\lib\msutil.jar
If you are using the SQL Server 2005 version, you will need:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
and
CLASSPATH=.;C:\JDBC\sqljdbc_1.0\enu\sqljdbc.jar
--------------------
Thread-Topic: Class Not Found Exception
thread-index: AcYo+3NRe1QkARdfQGCCaXbKbFyiqg==
X-WBNR-Posting-Host: 147.56.101.155
From: "=?Utf-8?B?RGF2aWQ=?=" <David@xxxxxxxxxxxxxxxxxxxxxxxxx>
Subject: Class Not Found Exception
Not new to programming, but very new to Java...
I have written a Java app that is attempting to connect to a local SQL
Server. I've downloaded and installed Microsoft's JDBC driver (it appeared to
install okay).
The following code is throwing the Class Not Found exception at the class
statement. Is there something more that I need to do with the driver that
I've installed or am I missing something in the code?
thanks for any help.
java.sql.Connection connection = null;
String username = "myName";
String password = "myPass";
String URL = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String conn = "jdbc:microsoft:sqlserver://localhost:1433:DatabaseName=myDB";
try {
Class.forName(URL).newInstance();
connection = DriverManager.getConnection(conn, username, password);
... rest of code
--
This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.
- References:
- RE: Class Not Found Exception
- From: Evan T. Basalik (MSFT)
- RE: Class Not Found Exception
- From: David
- RE: Class Not Found Exception
- Prev by Date: Re: sql driver 2005 - Null
- Next by Date: Re: JDBC Driver API Documentation in Javadocs?
- Previous by thread: RE: Class Not Found Exception
- Next by thread: Re: Class Not Found Exception
- Index(es):
Relevant Pages
|