Question

postgres is running at local host.

I am trying to get connected with db named sample from my java program.

And i placed my java program (JDBCExample.java)to connect db and jdbc driver in the same directory.

Now i execute the command

postgresconnection$ java -cp postgresql-9.3-1101.jdbc3.jar JDBCExample

Error: Could not find or load main class JDBCExample

How to fix this.

Was it helpful?

Solution

Try:

postgresconnection$ java -cp .:postgresql-9.3-1101.jdbc3.jar JDBCExample

Basically, you need to set the current dir in the classpath, java doesn't add it automatically.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top