import java.sql.*;
public class Main {
public static void main(String[] args) {
try {
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection(url_removed);
} catch (SQLException ex) {
System.out.println(ex.getMessage());
} catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
}
}
}
When I use java Main it throws ClassNotFoundException, as it cannot find class org.postgresql.Driver, meaning I have to tell where it's located (the .jar file), but I don't know how to do that.
Show differencesHistory of post edits
#ActualRipiz
Posted 10 May 2012 - 09:05 AM
It's in the original post. If you wish everything then here it is:
#4Ripiz
Posted 10 May 2012 - 09:04 AM
It's in the original post. If you wish everything then here it is:
import java.sql.*;
public class Main {
public static void main(String[] args) {
try {
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection(url_removed);
} catch (SQLException ex) {
System.out.println(ex.getMessage());
} catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
}
}
}
When I use java Main it throws ClassNotFoundException without the .jar, as it cannot find class org.postgresql.Driver, meaning I have to tell where it's located (the .jar file), but I don't know how to do that.
#3Ripiz
Posted 10 May 2012 - 09:01 AM
It's in the original post. If you wish everything then here it is:
It throws ClassNotFoundException without the .jar, as it cannot find class org.postgresql.Driver.
import java.sql.*;
public class Main {
public static void main(String[] args) {
try {
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection(url_removed);
} catch (SQLException ex) {
System.out.println(ex.getMessage());
} catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
}
}
}
It throws ClassNotFoundException without the .jar, as it cannot find class org.postgresql.Driver.
#2Ripiz
Posted 10 May 2012 - 09:00 AM
It's in the original post. If you wish everything then here it is:
It throws ClassNotFoundException without the .jar, as it cannot find classes.
import java.sql.*;
public class Main {
public static void main(String[] args) {
try {
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection(url_removed);
} catch (SQLException ex) {
System.out.println(ex.getMessage());
} catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
}
}
}
It throws ClassNotFoundException without the .jar, as it cannot find classes.
#1Ripiz
Posted 10 May 2012 - 08:59 AM
It's in the original post. If you wish everything then here it is:
import java.sql.*;
public class Main {
public static void main(String[] args) {
try {
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection(url_removed);
} catch (SQLException ex) {
System.out.println(ex.getMessage());
} catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
}
}
}