From: CR20 <mez283em23e2ze2@yahoo.com>
To: pgsql-admin@lists.postgresql.org
Subject: Ver. 12.1 successfully installed on Win 10 but having trouble with jdbc jar
Date: Sun, 19 Jan 2020 19:24:40 -0500
Message-ID: <7d2f92c9-a779-832b-849e-a38f929375d6@yahoo.com> (raw)
References: <7d2f92c9-a779-832b-849e-a38f929375d6.ref@yahoo.com>
Hi,
I have postgresql-12.1-3-windows-x64 installed and apparently working,
but I'm then I'm trying a simple Java connection example as follows:
import java.sql.*;
public class CreateTable {
public static void main(String args[]) {
Connection c = null;
Statement stmt = null;
String CreateSql = null;
try {
Class.forName("org.postgresql.Driver");
c =
DriverManager.getConnection("jdbc:postgresql://localhost:5432/procedure_demo",
"postgres", "adminedb");
System.out.println("Database Connected ..");
stmt = c.createStatement();
CreateSql = "Create Table Test(id int primary key, name
varchar, address text) ";
stmt.executeUpdate(CreateSql);
stmt.close();
c.close();
}
catch (Exception e) {
System.err.println( e.getClass().getName()+": "+
e.getMessage() );
System.exit(0);
}
System.out.println("Table Created successfully");
}
}
...which compiled successfully but when I go to run it, with
postgresql-42.2.9.jar stored in path C:\PostgreSQL\libs, like as follows:
java -cp C:\PostgreSQL\libs . CreateTable
...the command line returns:
Error: Could not find or load main class .
Some of this is my limited knowledge of Java. My question then is,
Where should the jdbc jar be located in order to run, and then how do I
run all this at the command line? Thank you for any help.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: mez283em23e2ze2@yahoo.com, pgsql-admin@lists.postgresql.org
Subject: Re: Ver. 12.1 successfully installed on Win 10 but having trouble with jdbc jar
In-Reply-To: <7d2f92c9-a779-832b-849e-a38f929375d6@yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox