User Tools

Site Tools


classes:general:dbsamples:java_postgres

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
classes:general:dbsamples:java_postgres [2017/01/14 19:56] – [Sample Compilation] localadminclasses:general:dbsamples:java_postgres [2018/11/13 11:58] (current) localadmin
Line 8: Line 8:
 This program connects to the database, runs the query, and iterates through a ResultSet containing the query results and displays the first item of each result to the screen. This program connects to the database, runs the query, and iterates through a ResultSet containing the query results and displays the first item of each result to the screen.
  
-You can find the PostgreSQL JDBC library at [[http://jdbc.postgres.org|the main postgres JDBC library page]]+You can find the PostgreSQL JDBC library at [[https://jdbc.postgresql.org/|the main postgres JDBC library page]]
  
 Make sure to have the appropriate PostgreSQL JDBC library in your CLASSPATH or loaded into your Java IDE. Make sure to have the appropriate PostgreSQL JDBC library in your CLASSPATH or loaded into your Java IDE.
Line 111: Line 111:
 </code> </code>
  
 +===== Setting the classpath explicitly =====
 +
 +Should that not work, you can explicitly set the classpath for the `javac` and `java` commands as such:
 +<code>
 +java -classpath "./:/path/to/postgresql-9.0-801-jdbc4.jar" DBCon.java
 + - and -
 +javac -classpath "./:/path/to/postgresql-9.0-801-jdbc4.jar" DBCon
 +</code>
 +
 +You use the -classpath switch to set the classpath. The classpath parameter is then a colon-delimited list of directories and .jar files that you would like to have included. The directory that your program resides in needs to be specified as well as the path to the postgresql JDBC .jar file. Using './' refers to the current directory. 
classes/general/dbsamples/java_postgres.1484445370.txt.gz · Last modified: 2017/01/14 19:56 by localadmin