Re: JDBC

From: Tim Freund <tim(at)technofreund(dot)com>
To: Armin Preis <preisa(at)sbox(dot)tugraz(dot)at>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: JDBC
Date: 2001-04-08 23:11:26
Message-ID: 20010408181126.A23781@technofreund.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'll answer the code question last since you need a working classpath
first... ;-)

I pondered the class path issue for a long time. I will assume you are
using bash or something similiar, since that's what I know -- make appropriate
substitutions.

To see your current CLASSPATH:
echo $CLASSPATH

To set your classpath:
export CLASSPATH=/javadirectory/jarname.jar:/javadirectory/jar2.jar:

To add your postgres jar onto your current classpath, do this:
export CLASSPATH=$CLASSPATH:/usr/lib/pgsql/jdbc6.5-1.2.jar

Alternatively, if all of your programs are going to use JDBC, you can
copy jdbc6.5-1.2.jar to /usr/java/jdk1.3/jre/lib/ext -- that will automatically
load the jdbc action on JVM start up.

Let me know if you run into problems....

Tim
--
/* Tim Freund -- tim(at)technofreund(dot)com */

> Is the following code ok?
Your code was close, but you were missing an org. in front of
postgresql.Driver -- try this:

import java.io.*;
import java.lang.*;
import java.sql.*;

public class jdbcTest {
public static void main(String args[]){
Connection con = null;
String url = "jdbc:postgresql:dbname";
String username = "username";
String password = "password";

try{
Class.forName("org.postgresql.Driver");
con = DriverManager.getConnection(url, username, password);

} catch(SQLException e){
e.printStackTrace(System.out);
} catch(ClassNotFoundException e){
e.printStackTrace(System.out);
}
}
}

In response to

  • JDBC at 2001-04-06 14:08:16 from Armin Preis

Browse pgsql-general by date

  From Date Subject
Next Message Yasuo Ohgaki 2001-04-09 00:07:06 PQexec() with multiple sql statements.
Previous Message Richard Boyes 2001-04-08 23:00:04 linux/bsd