Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
PostgreSQL/Eclipse/Tomcat - How to connect to DB?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="John C. Bollinger, post: 587771"] Probably not necessary, but shouldn't cause a problem. Define "do not compile well". Do you get a compilation error? If so, then something is dreadfully wrong. The documentation for the PostgreSQL JDBC driver should indicate which is the appropriate driver class. The name you are using looks reasonable, but that doesn't mean it's right. The driver documentation should also indicate the correct form for the DB URL to pass to DriverManager.getConnection(). If you do not use a form that the driver recognizes then your connection attempt will surely fail. Furthermore, you must be sure that you are attempting to connect to the IP port that Postgres is running on, which will be part of the server configuration. Also, most database servers support multiple databases, so I am not entirely sure what you mean when you say that "template1" is a database name from server installation time. Did the installer offer you an option to create a database? Otherwise, you will probably have to use the Postgres tools to create the database you want to use before you can connect to it. Again with the not compiling well. Post the error message(s) you get if you want any specific help. It's not clear to me whether or not you are successfully compiling the servlet, but the code you provide looks okay to me. It will not, however, do anything with any DB connection it manages to obtain. How are you testing? You do not need to execute Class.forName() on each request. Put it in the servlet's init() method instead. The form of the method invocation appears right, though, and the multiple invocations will not prevent obtaining a connection. If you do not need to provide username and password then you should probably use the one-argument version of getConnection(). You really haven't given us much to go on. It would help a lot if we could see the relevant error messages from the console and / or log file. John Bollinger [email]jobollin@indiana.edu[/email] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
PostgreSQL/Eclipse/Tomcat - How to connect to DB?
Top