[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

jdbc odbc problem

Posted on 2002-06-11
7
Medium Priority
?
467 Views
Last Modified: 2010-05-18
hi,
i got the following error:
C:\>java JDBCTest3
java.lang.ClassNotFoundException: sun.jdbc.odbc.JbdcOdbcDriver


Here is my code:
import java.sql.*;
import java.io.*;
import java.util.*;

public class JDBCTest3
{

     public static void main(String[] args)
     {
     
          //String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
          String driver = "sun.jdbc.odbc.JbdcOdbcDriver";
          //String DBurl = "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=stanley;User=stanley;Password=xxxxxx";
          String DBurl = "jdbc:odbc:ciuser";
         
     
          try
          {
               String query ="create table testing (name char(20));";
               String name = "";
               
               Class.forName(driver);
               java.sql.Connection con = DriverManager.getConnection(DBurl, "ciuser", "ciuser");
/*
               String createProcedure = "drop procedure TEST_PROC; create procedure TEST_PROC " +
                "as " +
                "select * " +
                "from stanley";



               CallableStatement cs = con.prepareCall("{call TEST_PROC}");
               ResultSet rs = cs.executeQuery();


*/

               Statement stmt = con.createStatement();
               stmt.execute(query);


               
               //Statement ps = con.createStatement();
               //java.sql.ResultSet rs = ps.executeQuery(query);
               //while(rs.next())
               //{
                   
               //     name = rs.getString(1);
               //     System.out.println("name is "+name);
                   
               //}
               //System.out.println("select is ok");
               //rs.close();
               //cs.close();

               con.close();
          }
          catch(Exception e)
          {
               System.out.println(e);
               System.exit(1);    
          }
 
     }    
}
     
0
Comment
Question by:stanleyhuen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 6

Expert Comment

by:kotan
ID: 7071852
make sure the package sun.jdbc.odbc.JbdcOdbcDriver is in ur classpath.
0
 
LVL 9

Expert Comment

by:Ovi
ID: 7071990
Reinstall your jdk.
0
 

Expert Comment

by:thangnt
ID: 7072125
Hi,

I think you miss something in your code, please see it in below :)

Thanks,

import java.sql.*;
import java.io.*;
import java.util.*;

public class JDBCTest3
{

    public static void main(String[] args)
    {
   
         //String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
         String driver = "sun.jdbc.odbc.JbdcOdbcDriver";
         //String DBurl = "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=stanley;User=stanley;Password=xxxxxx";
         String DBurl = "jdbc:odbc:ciuser";
         
     
         try
         {
              String query ="create table testing (name char(20));";
              String name = "";
             
              //This is your missing
              Class.forName(driver);
              //////////////////////////////////////
              //And this is my idea
              //Class.forName(driver).newInstance();
              //////////////////////////////////////

              java.sql.Connection con = DriverManager.getConnection(DBurl, "ciuser", "ciuser");
/*
              String createProcedure = "drop procedure TEST_PROC; create procedure TEST_PROC " +
               "as " +
               "select * " +
               "from stanley";



              CallableStatement cs = con.prepareCall("{call TEST_PROC}");
              ResultSet rs = cs.executeQuery();


*/

              Statement stmt = con.createStatement();
              stmt.execute(query);


             
              //Statement ps = con.createStatement();
              //java.sql.ResultSet rs = ps.executeQuery(query);
              //while(rs.next())
              //{
                   
              //     name = rs.getString(1);
              //     System.out.println("name is "+name);
                   
              //}
              //System.out.println("select is ok");
              //rs.close();
              //cs.close();

              con.close();
         }
         catch(Exception e)
         {
              System.out.println(e);
              System.exit(1);    
         }

    }    
}
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:Venci75
ID: 7072129
... or add
<JAVA_PATH>\jre\lib\rt.jar to your class path.

0
 

Author Comment

by:stanleyhuen
ID: 7072173
Thanks.

Sorry, I found the mistake now.
It is typing mistake:
sun.jdbc.odbc.JbdcOdbcDriver

should be:


sun.jdbc.odbc.JdbcOdbcDriver
0
 

Accepted Solution

by:
YSaadat earned 800 total points
ID: 7072315
Hi,

Here is a silly mistake.
check the spelling
String driver = "sun.jdbc.odbc.JbdcOdbcDriver";
         
It should be
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";

Regards
Saadat
0
 
LVL 9

Expert Comment

by:Venci75
ID: 7072318
good answer :))
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question