java.lang.NoClassDefFoundError: com/microsoft/jdbc/base/BaseDriver



Hello

This is really irritating.

Trying to connect to an SQL Server 2000 database using MS SQL JDBC (the MS implementation).

Keep getting the above error and I have checked CLASSPATH repeatedly to make sure msbase.jar, mssqlserver.jar and msutil.jar are listed in it. Have copied the relevant jars to working directory with no success. All I am trying to do is gain a connection to the database. I have googled around and cannot find much to help. The basic response issue seems to be a missing class but I am sure that CLASSPATH is set properly.

My CLASSPATH is c:\j2sdk1.4.2_07\lib;C:\Program Files\Microsoft SQL Server JDBC\lib\mssqlserver.jar;C:\Program Files\Microsoft SQL Server JDBC\lib\msbase.jar;C:\Program Files\Microsoft SQL Server JDBC\lib\msutil.jar

The class compiles but will not execute.

What am I missing?

Thanks

Sam Benson


The code is as follows (straight from MS website): <code> import java.*; public class Connect{ private java.sql.Connection con = null; private final String url = "jdbc:microsoft:sqlserver://"; private final String serverName= "localhost"; private final String portNumber = "1433"; //private final String databaseName= "ABADAT"; private final String databaseName= ""; private final String userName = "sa"; private final String password = "secret"; // Informs the driver to use server a side-cursor, // which permits more than one active statement // on a connection. private final String selectMethod = "cursor";

     // Constructor
     public Connect(){}

private String getConnectionUrl(){
return url+serverName+":"+portNumber+";databaseName="+databaseName+";selectMethod="+selectMethod+";";
}


     private java.sql.Connection getConnection(){
          try{

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = java.sql.DriverManager.getConnection(getConnectionUrl(),userName,password);
if(con!=null) System.out.println("Connection Successful!");
}catch(Exception e){
e.printStackTrace();
System.out.println("Error Trace in getConnection() : " + e.getMessage());
}
return con;
}


     /*
          Display the driver properties, database details
     */

public void displayDbProperties(){
java.sql.DatabaseMetaData dm = null;
java.sql.ResultSet rs = null;
try{
con= this.getConnection();
if(con!=null){
dm = con.getMetaData();
System.out.println("Driver Information");
System.out.println("\tDriver Name: "+ dm.getDriverName());
System.out.println("\tDriver Version: "+ dm.getDriverVersion ());
System.out.println("\nDatabase Information ");
System.out.println("\tDatabase Name: "+ dm.getDatabaseProductName());
System.out.println("\tDatabase Version: "+ dm.getDatabaseProductVersion());
System.out.println("Avalilable Catalogs ");
rs = dm.getCatalogs();
while(rs.next()){
System.out.println("\tcatalog: "+ rs.getString(1));
}
rs.close();
rs = null;
closeConnection();
}else System.out.println("Error: No active Connection");
}catch(Exception e){
e.printStackTrace();
}
dm=null;
}


     private void closeConnection(){
          try{
               if(con!=null)
                    con.close();
               con=null;
          }catch(Exception e){
               e.printStackTrace();
          }
     }
     public static void main(String[] args) throws Exception
       {
          Connect myDbTest = new Connect();
          myDbTest.displayDbProperties();
       }
}
</code>
.



Relevant Pages

  • Re: Linking tables access - sql server 2005
    ... Another advantage of this method is that you don't need an ODBC setting on the local computer, ... Create a linked table to SQL Server without using a DSN ... Name of the table that you are linking to on the SQL Server database ... Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName As String, stServer As String, stDatabase As String, Optional stUsername As ...
    (microsoft.public.access.adp.sqlserver)
  • Re: ADO beginner questions
    ... I would guess that a database would be the appropriate tool to use to ... > Sub CountLengths ... > Private msDbFilename As String ...
    (microsoft.public.vb.database.ado)
  • Re: Changing Connection String programmatically
    ... Connection strings of different years can be stored in app.config ... is declared in MyDataset.Designer.cs as private, ... every year we will create new database. ... If you are storing connnection string information related to additional ...
    (microsoft.public.sqlserver.connect)
  • RE: RDA problems - please help
    ... This is my code where I set up the connection and then try to pull a table: ... // The local connection string. ... private string strURL = "http://Gardar/AdveitaDataSync/sscesa20.dll";; ... I use something like this to create a database on the moblie device, connect to the SQL server and pull data down to the device: ...
    (microsoft.public.pocketpc.developer)
  • Re: Help: Login failed for User ???
    ... You can test database access by creating an empty file with as UDL extension ... The SQL Server will need to be a member server of the domain as will the ... I tried using the new version of the connect string and have the same ... I login Windows, Run application, I can get ...
    (microsoft.public.dotnet.framework.adonet)