Jon
Jon Camilleri wrote: Directory of C:\Program Files\PostgreSQL\pgJDBC
09/07/2011 15:42 <DIR> .
09/07/2011 15:42 <DIR> ..
03/04/2011 23:22 502,118 postgresql-8.4-702.jdbc3.jar
03/04/2011 23:22 539,510 postgresql-8.4-702.jdbc4.jar
09/07/2011 15:42 <DIR> scripts
09/07/2011 15:42 5,759,102 uninstall-pgjdbc.exe
3 File(s) 6,800,730 bytes
3 Dir(s) 37,261,746,176 bytes free
C:\Program Files\PostgreSQL\pgJDBC>java -jar postgresql-8.4-702.jdbc.3.jar
Unable to access jarfile postgresql-8.4-702.jdbc.3.jar
C:\Program Files\PostgreSQL\pgJDBC>java -jar postgresql-8.4-702.jdbc.4.jar
Unable to access jarfile postgresql-8.4-702.jdbc.4.jar
Jesper de Jong wrote:Directory of C:\Program Files\PostgreSQL\pgJDBC
Look closely at the filenames you typed. You made a mistake.
Jesper de Jong wrote:
Also, JDBC drivers are most likely not executable JAR files that you can run with the java -jar command (why are you trying to do that?). Just put the JAR file in your classpath when you run your own program that needs it. Do not put these JAR files in your jre6\lib\ext directory.
Run your program with a command like this:
java -cp postgresql-8.4-702.jdbc4.jar;. TestDB
The 3 and 4 in the names of the JAR files most likely do not have anything to do with JDBC Type 3 and 4 drivers. It is most likely a driver for JDBC version 3 (Java 5 and older) or JDBC version 4 (Java 6 and newer).
Jon
Jon Camilleri wrote:Yep, sorry, but in any case I am getting the following error now:
C:\Program Files\PostgreSQL\pgJDBC>java -jar postgresql-8.4-702.jdbc3.jar
Failed to load Main-Class manifest attribute from
postgresql-8.4-702.jdbc3.jar
Jon Camilleri wrote:
Thanks but I don't read any good news:
...
>java -cp postgresql-8.4-702.jdbc4.jar; .TestDB
Exception in thread "main" java.lang.NoClassDefFoundError: /TestDB
Caused by: java.lang.ClassNotFoundException: .TestDB
Jesper de Jong wrote:
java -cp postgresql-8.4-702.jdbc4.jar;. TestDB
That's java, -cp, name of the jar, semi-colon, dot, without spaces between the jar filename, semi-colon and dot, then a space, then the classname.
Please make an effort to understand what the commands you are typing and the error messages mean.
Jon
Ulf Dittmer wrote:You made the exact same mistake as before - the one that Jesper told you how to fix; please pay attention to every single detail of what he wrote.
Jon
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Jesper de Jong wrote:John, ok, that is what you need to do to make an executable JAR file.
But Jon is trying to run a JDBC driver library JAR as if it is an executable JAR file. Trying to do that makes no sense.
Jon
Jon Camilleri wrote:Excuse me, I was only following a book example; it would have been appreciated if you explained the reason for using the java -jar command. I was only trying to "tell Java that the JAR to use to run TestDB.class is the driver (postgresql-8.4-702.jdbc4.jar) provided by PostGre.
Jon Camilleri wrote:Why is a manifest file required for a driver anyway?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |