• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Class.forName()

 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.sql.*;
public class first{
public static void main(String[] args){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc.odbc.MyDataSource","sa","");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("Select * from authors");
rs.beforeFirst();
while(rs.next()){
String id=rs.getString("au_id");
System.out.print(id);
}
rs.close();
}

catch(Exception e){
System.out.println(e);
}

}
}

Helo frnd In the above code it is throwing a exception that not sutable driver why ?

with regard

Arun
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the JDBC forum.
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thers is nothing wrong in Class.forName(). Problem is at the time of connection.

At the time of connection, you need to provide three thing.. jdbc_url, username and password.



Your jdbc url is not correct. It should be "jdbc:odbc:MyDataSource" instead of "jdbc.odbc.MyDataSource".


Naseem
[ July 13, 2006: Message edited by: Naseem Khan ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic