aspose file tools*
The moose likes JDBC and the fly likes SQL Server 2000 Database Connection using JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Server 2000 Database Connection using JDBC" Watch "SQL Server 2000 Database Connection using JDBC" New topic

SQL Server 2000 Database Connection using JDBC

Rajesh Rami Reddy

Joined: Mar 04, 2008
Posts: 5
Hello Friends,

I had wrote a programme for connecting the Sql Server 2000 DataBase using JDBC.Programe code is

import java.sql.*;

public class createTable
public static void main (String[] args)
DB db = new DB();
Connection conn=db.dbConnect(


class DB
public DB() {}

public Connection dbConnect(String db_connect_string,
String db_userid, String db_password )
Connection conn = DriverManager.getConnection(
db_connect_string, db_userid, db_password);
System.out.println ("connected");
return conn;

catch (Exception e)
return null ;

public void createTables(Connection conn)
String query;
Statement stmt;

query="create table cust_profile " +
"(name varchar(32), " +
"address1 varchar(50), " +
"city varchar(50), " +
"state varchar(50), " +
"country varchar(50))";
stmt = conn.createStatement();
stmt.executeUpdate( query);
catch (Exception e)

When i was run this programme it was displayed as

at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at DB.dbConnect(
at createTable.main(
at DB.createTables(
at createTable.main(

i had set the CLASSPATH as "C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;C:\Program Files\Java\jdk1.5.0\jre\lib\sqlserver.jar"

Could you know any one where i did a mistake. Please inform me at
Jan Cumps

Joined: Dec 20, 2006
Posts: 2476

Try to find the one driver jar that you need, and add that to your classpath. It seems like you have added different (versions of?) sqlserver jars.

Try if putting the driver in a folder without spaces helps.

These people had a similar issue: Upgrading to SQL Server 2005 JDBC driver (SQLJDBC.jar) causes connection failure for exising SQLService
You will notice that the path is different in the SQL 2005 driver to that provided in the SQL 2000 driver.

Class.forName(""); // 2005 version
Class.forName(""); // 2000 version

Regards, Jan

OCUP UML fundamental and ITIL foundation
youtube channel
I agree. Here's the link:
subject: SQL Server 2000 Database Connection using JDBC
Similar Threads
Trying to grab the last record.
cannot find javax/crypto/spec/SecretKeySpec class inTomcat 6
Mysql JDBC Cant load.....
Problems regarding MS JDBC Driver and JTDS-JDBC Connectivity for MS SQL Server 2000
Viewing data from database into an xls format not working