Обсуждение: suitable driver not found
The code given below gives an exception as:
a suitable driver not found.
I am not working on a network, it is a simple stand alone PC.
Which jdbc driver would be suitable,I am using postgreSQL 7.3,j2sdk1.4.2 and have installed jdbc driver pg73jdbc3.jar
import java.sql.*;
class mycon{
public static void main (String args[]) {
try{
Class.forName("org.postgresql.Driver");
String url="jdbc:postgresql://127.0.0.1:5432/a;
Connection con = DriverManager.getConnection(url, "postgres", "");
import java.sql.*;
class mycon{
public static void main (String args[]) {
try{
Class.forName("org.postgresql.Driver");
String url="jdbc:postgresql://127.0.0.1:5432/a;
Connection con = DriverManager.getConnection(url, "postgres", "");
}catch(ClassNotFoundException e) {
System.out.println("Exception");
System.out.println(e.toString());
}
catch(SQLException e) {
System.out.println("Exception");
System.out.println(e.toString());
}
}
}
System.out.println("Exception");
System.out.println(e.toString());
}
catch(SQLException e) {
System.out.println("Exception");
System.out.println(e.toString());
}
}
}
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
On Sat, 31 Jan 2004, poonam talreja wrote: > The code given below gives an exception as: > a suitable driver not found. > > Class.forName("org.postgresql.Driver"); > String url="jdbc:postgresql://127.0.0.1:5432/a; > Connection con = DriverManager.getConnection(url, "postgres", ""); > The two common reasons for no suitable driver found are forgetting Class.forName and making a typo in the url which makes it invalid for postgresql. You seem to have the forName working well, but it is tough to tell what is going on here because this is obviously not exactly what you are using because it is missing and end " on the url. Please examine your connection url carefully and report back with the exact string used if that does not solve your problme. Kris Jurka