RE: Class Not Found Exception



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.


.



Relevant Pages

  • Re: Installing SBS2k3 CEICW Network Error
    ... DHCP Server 192.168.0.1-254. ... Internal NIC gets 192.168.16.2 from SBS2k3 DHCP server. ... Boot SBS2k3 from CD1 in CD-ROM and start install. ... > Leave the box talking about a single network connection unchecked, ...
    (microsoft.public.windows.server.sbs)
  • Re: Install Ubuntu without CDROM
    ... floppy, just a net connection, and the net connection supports net ... To install Ubuntu ... We'll call this "Server PC". ... F. Disconnect the Server PC from the Internet and plug the Client PC up ...
    (comp.os.linux.setup)
  • RE: Cannot create a VPN connection using PPTP from 2003 Server
    ... Run this command to install the WAN Miniport: ... If I pass a bad username or password the connection asks for the correct ... another server on the Internet by creating a VPN connection. ... connection uses PPTP and has been running fine until recently. ...
    (microsoft.public.windows.server.networking)
  • Re: Unable to establish the VPN connection. (Error 800) in SBS 2003
    ... make sure you have installed all the updates on the server. ... to add some keys in the registry, but if you install all the updates, it ... We tried to connect some clients over VPN, ... may not be configured properly for his connection. ...
    (microsoft.public.windows.server.sbs)
  • Re: I can send but I cant receive
    ... sending while away from your home ISP connection, ... Your AVG antivirus was probably installed with its default install option. ... Your server has unexpectedly terminated the connection. ... Subject 'test', Account: 'pop.charter.net', Server: ...
    (microsoft.public.windows.vista.mail)

Quantcast