I'm trying to compile and run java program with JDBC in terminal. I typed:
javac -sourcepath src:lib -cp lib/postgresql-9.2-1002.jdbc4.jar:lib/otherlibraries src/Database.java
Later I tried to run it:
java -cp src:lib/postgresql-9.2-1002.jdbc4.jar:otherlibraries Database
But when i tried to find driver:
try
{ Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException ex)
{...}
I got the error that no suitable driver was found, but when i run program in NetBeans I could connect to database. Unfortunately, I have to do it by terminal. What I did wrong?
- Postgresql: 9.5.7
- Java: 1.8
- JDBC: postgresql-9.2-1002.jdbc4