Thread: Error:java.lang.ClassNotFoundException: org.postgresql.Driver
Hi All,
I am working on java project to insert and fetch data from postgresql database. While using jbdc I am getting error"java.lang.ClassNotFoundException: org.postgresql.Driver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at SqlConnection.sql_connection(SqlConnection.java:29)
at ServerConnection.run(ServerConnection.java:205)
at java.lang.Thread.run(Thread.java:745)
"
"jdbc:postgresql://127.0.0.1:5432/testdb";
public int sql_connection(String outletid, String messageid, String checkid,int msgarry,String message,PrintStream os)
{
String []lines = message.split("\\?");
String [] separated = lines[0].split("\\|");
//for(int i=0;i<4;i++)
//System.out.println("received msg from client :"+separated[i]);
msgformation pack = new msgformation();
System.out.println("sizes---: " +separated.length+" ---Arry Received: "+ msgarry);
if(separated.length==msgarry){
try{
System.out.println("Connecting to database...");
Properties password = new Properties();
password.put("user","postgress");
password.put("password","postgress");
password.put("host","localhost");
Class.forName("org.postgresql.Driver");
//DriverManager.register(org.postgresql.Driver());
ServerMain.conn = DriverManager.getConnection(DB_URL,password);
"
"export CLASSPATH=./Server.jar:~/Downloads/postgresql-9.3-1103.jdbc3.jar"
Server.jar is main executable file.