import java.sql.*; import java.util.*; class MyDbCode3 {
public static void main(String [] args) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(ClassNotFoundException cnf) { System.out.println("Cannot load the Driver"); System.exit(1); } Scanner kb=new Scanner(System.in); int id; System.out.println("Enter bookid:"); id=kb.nextInt(); try { Connection conn=DriverManager.getConnection("jdbc:odbc:advdsn1","student","myself"); Statement st=conn.createStatement(); String qry="Update mybooks set price=price+1000 where bookid="+id; System.out.println(qry); int x=st.executeUpdate(qry); System.out.println("Rows effected="+x); conn.close(); } catch(SQLException sq) { System.out.println("Sql Error:"+sq.getMessage()); } } }
I have created Dsn Successfully ,table also has been created successfully and when i compiled this program then it compiled successfully ,but when i run it ,it gives following error->
C:\Program Files\Java\jdk1.5.0\bin>java MyDbCode3 Enter bookid: 101 Sql Error:[Microsoft][ODBC Driver Manager] Data source name not found and no def ault driver specified
i want to know what is the problem? and how can i run it successfully? please give me a satisfieng answer ,bcz i am not satisfied by ur previous answer...
thank u ....
Ads