i am new in database want to run first database progrom with oracle but getting error java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
i wrote following code
// DDL(Data Definition Language)
// Two commands
// 1. create
// 2. insert
// To execute this command used method create
// create command
import java.sql.*;
import java.io.*;
class create
{
public static void main(String[] args)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers loaded");
Connection con=DriverManager.getConnection("jdbc:odbc:new","system","cse");
System.out.println("Connection established");
Statement st=con.createStatement();
st.execute("Create table student(sno varchar(20),sname varchar(20),sadd varchar(20))");
System.out.println("Table created");
st.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
If you are trying to connect to a Oracle database (eg Oracle 10g) then you should not be using the JDBC / ODBC bridge. You should be using the appropriate Oracle drivers, and a JDBC URL of the appropriate type. This Q&A covers this topic:
There is more information on the Oracle website.
The JDBC / ODBC bridge are for connecting to a database that "speaks" ODBC; eg Microsoft Access or Excel. If this is what you really require, then you need a 3rd-party JDBC / ODBC bridge driver. Java 8 and later no longer include this driver, as described in this Q&A:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.