Как включить JAR-файл postgresql в Java-приложение с использованием IDE VS-кода?JAVA

Программисты JAVA общаются здесь
Гость
Как включить JAR-файл postgresql в Java-приложение с использованием IDE VS-кода?

Сообщение Гость »


I have downloaded jar file and added it to Reference Libraries section in VS code.
Изображение


but when I have run below code I am getting exception in 10th and 11th line.

import java.sql.*;;; public class Demo { public static void main(String[] args) { String url; String user; String passWord; url = "jdbc:postgresql://localhost:5432/Demo"; user = "Postgres"; passWord = "0000"; try {Class.forName("org.postgresql.Driver");} catch (ClassNotFoundException e) {System.out.println("Exception in first try - "+e);;} try {Connection con = DriverManager.getConnection(url, user, passWord);} catch (Exception e) {System.out.println("Exception in second try "+e);;} System.out.println("connection got established"); } } Error I am getting -

Exception in first try - java.lang.ClassNotFoundException: org.postgresql.Driver Exception in second try java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/Demo connection got established I have spend lot of time to find cause of this issue, please help me to fix this one.


Источник: https://stackoverflow.com/questions/780 ... s-code-ide

Вернуться в «JAVA»