File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Class.forName() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Class.forName()" Watch "Class.forName()" New topic


Arun Maalik
Ranch Hand

Joined: Oct 25, 2005
Posts: 216
import java.sql.*;
public class first{
public static void main(String[] args){
Connection con=DriverManager.getConnection("jdbc.odbc.MyDataSource","sa","");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("Select * from authors");
String id=rs.getString("au_id");

catch(Exception e){


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

with regard

marc weber

Joined: Aug 31, 2004
Posts: 11343

Moving to the JDBC forum.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
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 "jdbcdbc:MyDataSource" instead of "jdbc.odbc.MyDataSource".

[ July 13, 2006: Message edited by: Naseem Khan ]

Asking Smart Questions FAQ - How To Put Your Code In Code Tags
I agree. Here's the link:
subject: Class.forName()