package ru.javadev; import java.sql.Connection; import java.sql.Driver; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.Enumeration; public class App1 { public static void main(String[] args) { Connection conn = null; Statement stmt = null; try { // Class.forName("oracle.jdbc.OracleDriver"); Class.forName("org.postgresql.Driver"); Enumeration<Driver> en = DriverManager.getDrivers(); while (en.hasMoreElements()){ Driver driver = (Driver) en.nextElement(); System.out.println(driver); } // conn = DriverManager.getConnection("jdbc:oracle:thin:@135.135.137.26:1521:anna", "scott", "tiger"); conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/mydatabase", "scott", "tiger"); System.out.println("Connected..."); System.out.println("DataBase version: " + conn.getMetaData().getDatabaseProductVersion()); System.out.println("is AutoCommit: " + conn.getAutoCommit()); conn.setAutoCommit(false); System.out.println("is AutoCommit: " + conn.getAutoCommit()); stmt = conn.createStatement(); stmt.execute("create table q (q numeric)"); System.out.println("ALL OK!"); } catch (Exception e){ System.out.println("Error: " + e); } finally { try { stmt.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { conn.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } Console output: Connected... DataBase version: 8.4.20 is AutoCommit: true is AutoCommit: false ALL OK!