Re: Can't connect to posgresql through the jdbc driver
От | Craig Ringer |
---|---|
Тема | Re: Can't connect to posgresql through the jdbc driver |
Дата | |
Msg-id | 4B8DD56F.9040109@postnewspapers.com.au обсуждение исходный текст |
Ответ на | Can't connect to posgresql through the jdbc driver (Lior K <liork20002000@yahoo.com>) |
Ответы |
Re: Can't connect to posgresql through the jdbc driver
|
Список | pgsql-jdbc |
[ Replying to list, since poster replied directly to me. I've trimmed the reply and fixed the broken quoting; please quote correctly in future replies and reply to the list, not directly to me]. Lior K wrote: >> Craig Ringer wrote: >> What's the exact value of CLASSPATH as you set it? > > from within .bashrc : > > CLASSPATH=$CLASSPATH:/opt/PostgreSQL/pgJDBC/ > export CLASSPATH > >> Did you set it to the directory containing the .jar ? Or to the .jar its >> self? You need to put the actual .jar on the CLASSPATH. > > I set it to the jar file as written above No, you didn't. You set it to the folder CONTAINING the jar. Try: CLASSPATH=$CLASSPATH:/opt/PostgreSQL/pgJDBC/postgresql-8.4-701.jdbc.jar > I am using netbeans 6.8 ... The project I chose was a java application . The application is supposed to connect to a databasewhich parameters (DB name , userName,Password ) I pass through netbeans config file option (under the "run" sectionin the menu. I also tried to run it manually with this line: Eh? If you're using NetBeans, why are you messing with the CLASSPATH environment variable? Just define libraries and add them to your netbeans project. See the netbeans introductory tutorial, the built-in help, the "Libraries" folder in the project, and the "Libraries" entry in the Tools menu. For example, I created a library "PostgreSQL JDBC Driver", and added the postgresql-8.4-701.jdbc.jar to it. If I wanted to use that in an Ant project (the default netbeans project type) I'd just right-click on the library list and add "PostgreSQL JDBC Driver" to the list. Now netbeans will add it to the classpath automatically, copy it into the dist folder when I do a project build, bundle it up in my application jar when I do a jar build, and otherwise just take care of it for me. If you add the sources and javadoc to the library too, you get source-level debuggging, JavaDoc autocomplete, etc for the library too. Right now, you're doing things the hard way! You'll get a lot further by reading the documentation in Netbeans and the basic documentation on the JVM, "java" command, etc. ( Alternately, if you use Maven, and add a dependency for: Artifact: postgresql Group: postgresql Version: 8.4-701.jdbc4 and it all automagically just happens ). -- Craig Ringer
В списке pgsql-jdbc по дате отправления: