cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver

Former Member
0 Kudos

Help!

I've created a simple program that should connect to a client of mine using jdbc. I was given the driver class which I have imported and added to my build path. I deploy the application and it errors saying it cannot find the class. Here is the code:

public void wdDoInit()
  {
    //@@begin wdDoInit()
    IWDMessageManager mm = wdThis.wdGetAPI().getComponent().getMessageManager();

    String host = "host";
    int port = 1433;
    String SID = "hostsid";
    String user = "username";
    String pass = "pwd";

    String driver_class = "net.sourceforge.jtds.jdbc.Driver";  
    String access = "jdbc:jtds:sqlserver://" + host + ":1433" + "/" + SID;
    Connection con;
        
     try
    {
      try
      {        
        Driver driver = (Driver)Class.forName(driver_class).newInstance();
       } catch (Exception e)
      {
        mm.reportWarning("msg = " + e.toString());
      }
      con = DriverManager.getConnection(access, user, pass);
    } catch (SQLException e)
    {
      mm.reportWarning("Error: " + e.getMessage());
    }

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi Steve,

Put jar file with JDBC driver to lib folder under your WD project and it will be included to wda and ear files.

BTW, may be it is beeter to register driver and datasource instead of using direct connect to DB? See how to register data source http://help.sap.com/saphelp_nw04/helpdata/en/b0/6e62f30cbe9e44977c78dbdc7a6b27/frameset.htm

Best regards, Maksim Rashchynski.

Answers (0)