java.lang.ClassNotFoundException: org.postgresql.Driver [solved]
1. In this video I have shown how you can solve the error.
1 2 3 4 5 6 7 8 9 |
java.lang.ClassNotFoundException: org.postgresql.Driver at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at com.jinujawad.com.ConnectDB.get_connection(ConnectDB.java:23) at com.jinujawad.com.ConnectDB.main(ConnectDB.java:10) |
2. This error came for me on running the below java program in Eclipse IDE.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
package com.jinujawad.com; import java.sql.Connection; import java.sql.DriverManager; public class ConnectDB { public static void main(String[] args) { ConnectDB obj_ConnectDB=new ConnectDB(); obj_ConnectDB.get_connection(); } public Connection get_connection() { Connection connection = null; String host="localhost"; String port="5432"; String db_name="jinujawad"; String username="postgres"; String password="root"; try { Class.forName("org.postgresql.Driver"); connection = DriverManager.getConnection("jdbc:postgresql://"+host+":"+port+"/"+db_name+"", ""+username+"", ""+password+""); if (connection != null) { System.out.println("Connection OK"); } else { System.out.println("Connection Failed"); } } catch (Exception e) { e.printStackTrace(); } return connection; } } |
…
Read more »How to take back up of PostgreSQL Database – Windows PC using CMD
In this video I have shown how to take back up of PostgreSQL database in windows PC using Command Prompt. This is demonstrated in windows 10 pc. 1. Open the…
Read more »How to Auto back up PostgreSQL Database
In this video I have shown how to create Auto Back up for PostgreSQL Database. This method is demonstrated in Windows 10 PC using task scheduler. 1. First create batch…
Read more »How to connect to PostgreSQL using JAVA JDBC
In this video I have shown how you can connect to PostgreSQL using JAVA JDBC. This example is shown in eclipse IDE. You should download the jar file from official…
Read more »