This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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 REST with Spring (video course) this week in the Spring 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()
It's not a secret anymore!