Answer the question
In order to leave comments, you need to log in
Why doesn't JDBC 4.2 work without Class.forName?
I work in Eclipse. I add dependency to pom.xml PostgreSQL JDBC Driver.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>14</maven.compiler.source>
<maven.compiler.target>14</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.20</version>
</dependency>
</dependencies>
</project>
Properties connProps = new Properties();
connProps.put("user", user);
connProps.put("password", password);
try {
Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost/", connProps);
} catch (SQLException e) {
e.printStackTrace();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question