Right, so I found the PostgreSQL JDBC driver here. Downloaded it and put it in my home folder which I then added to the CLASSPATH by adding the following lines to my .profile file:
when I echo $CLASSPATH in Terminal it shows up correctly, yet when I try and load the JDBC PostgreSQL driver in Netbeans it says class not found. I even added it as a library as well to the Netbeans project file.
I've also tried it from the command line and text editor and it still gives the following exception:
Source code:
Edit: Interestingly enough, the Netbeans 6.5 IDE allows me to connect to the database and use SQL commands using the JDBC driver but still will not run the code. That must mean that the driver is somewhere and is working it just is not picking it up at the project level for some strange reason.
Code:
CLASSPATH=".:/Users/simon/postgresql.jar"
export CLASSPATH
I've also tried it from the command line and text editor and it still gives the following exception:
I am most likely doing something silly as this is my first foray into Java.typhoonesktop simon$ javac Main.java
Main.java:14: unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown
Class.forName("org.postgresql.Driver");
^
1 error
Source code:
Code:
package javaone;
import java.sql.*;
public class Main
{
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Class.forName("org.postgresql.Driver");
}
}
Edit: Interestingly enough, the Netbeans 6.5 IDE allows me to connect to the database and use SQL commands using the JDBC driver but still will not run the code. That must mean that the driver is somewhere and is working it just is not picking it up at the project level for some strange reason.
Last edited: