Re: [JDBC] [Q] Can't get simple JDBC connection to work: "no suitable driver"

2001-10-12 Thread Liam Stewart


Try changing the connection url to the following:

"jdbc:postgresql:test"

This should do the trick. postgres is not a valid subprotocol which explains
the error message that you're getting. postgresql is the only subprotocol
recognized by the PostgreSQL JDBC driver.

Liam

On Thu, Oct 11, 2001 at 04:28:06PM -0700, Amandeep Jawa wrote:
> (PLEASE email any replies to me directy as well as posting)
> 
> Hey folks -
> 
> I hope someone can help.  I'm trying to get a VERY simple JDBC connection
> working with the JDBC drivers but I am consistently getting a "no suitable
> driver" error.
> 
> I am trying a very very simple test program to access my little PostgreSQL
> database & I am using the jdbc driver: jdbc7.1-1.2.jar (binary downloaded
> from www.postgresql.org).
> 
> The error I'm getting is:
> 
> Exception in thread "main" java.sql.SQLException: No suitable driver
> at java.sql.DriverManager.getConnection(DriverManager.java:537)
> at java.sql.DriverManager.getConnection(DriverManager.java:177)
> at testpost.main(testpost.java:14)
> 
> 
> The command I'm running is:
> 
> java -cp /usr/share/pgsql/jdbc7.1-1.2.jar testpost
> 
> The code is:
> 
> // testpost.java
> 
> import java.sql.*;
> 
> public class testpost
> {
> 
> public static void main(String argv[]) throws Exception
> {
> System.out.println("Beginning Postgres Test");
> Class.forName("org.postgresql.Driver");
> 
> System.out.println("Loaded Driver.");
>   Connection conn = DriverManager.getConnection(
> "jdbc:postgres:test",
> "postgres",
> "notreallymypassword"
> );
> 
> System.out.println("Got connection.");
> /* COMMENTED OUT UNTIL I KNOW THE REST WORKS
> Statement stmt = conn.createStatement();
> ResultSet rset = stmt.executeQuery("SELECT now();");
> 
> System.out.println("Ran now query..\nResults:\n");
> while (rset.next())
> {
> System.out.println(rset.getString(1));
> }  
> 
> rset.close();
> stmt.close();
>   */   
> conn.close();
> 
> System.out.println("Closed connection & Ended Test");
> 
> }
> 
> }
> 
> 
> 
> The ouput I get is:
> 
> Beginning Postgres Test
> Loaded Driver.
> Exception in thread "main" java.sql.SQLException: No suitable driver
> at java.sql.DriverManager.getConnection(DriverManager.java:537)
> at java.sql.DriverManager.getConnection(DriverManager.java:177)
> at testpost.main(testpost.java:14)
> 
> I'm using postgres 7.1.3 installed from RPMs (from Postgres) on Red Hat
> Linux 7.1 with Sun's jdk 1.3.1 also installed from RPMs (from Sun).
> 
> I have a "postgres" user on my machine.  I have made the database "test".
> Not that I think these things matter because it doesn't seem to be getting
> that far.  I am starting the postgres server from the root user with the
> following command:
> /etc/rc.d/init.d/postgresql start
> & it seems to be starting fine.  I have also turned on tcp-ip connections in
> the conf file.
> 
> Couple of other facts:
>  - One thing I notice is that the documentation all refers to a
> "postgressql.jar" which I can't find.  I can find the "jdbc7.1-1.2.jar"
> which is what I'm using.
> 
> - One other thing I have tried is to rebuild the drivers from scratch - this
> does give me a postgresql.jar - but the error is the same.
> 
> - I have also noticed that the jar files are not always the same size:
> jdbc7.1-1.2.jar from postgresql-jdbc-7.1.3-1PGDG.i386.rpm : 88169 bytes
> jdbc7.1-1.2.jar from jdbc.postgresql.org : 93011 bytes
> But the error is the same :-)
> 
> 
> Any help would be greatly appreciated - and please email replies to me
> directly as well as the list.
> 
> THANKS in advance.
> 'deep
> 
> 
> --
> Amandeep Jawa
> Worker Bee Software
> --
> [EMAIL PROTECTED]
> 225A Dolores St.
> San Francisco, CA 94103-2202
> 
> Home: 415 255 6257 (ALL MALP)
> 
> professional: http://www.worker-bee.com
> personal: http://www.deeptrouble.com
> political: http://www.sflcv.org
> 
> 
> 
> 
> 
> ---(end of broadcast)---
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to [EMAIL PROTECTED] so that your
> message can get through to the mailing list cleanly

-- 
Liam Stewart :: Red Hat Canada, Ltd. :: [EMAIL PROTECTED]

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



[JDBC] fix for JDBC test suite

2001-09-25 Thread Liam Stewart


A couple of lines were missing from my last patch - this one fixes things.

Liam


-- 
Liam Stewart :: Red Hat Canada, Ltd. :: [EMAIL PROTECTED]


Index: src/interfaces/jdbc/org/postgresql/test/jdbc2/TimestampTest.java
===
RCS file: 
/projects/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/test/jdbc2/TimestampTest.java,v
retrieving revision 1.3
diff -c -r1.3 TimestampTest.java
*** src/interfaces/jdbc/org/postgresql/test/jdbc2/TimestampTest.java2001/09/23 
04:11:14 1.3
--- src/interfaces/jdbc/org/postgresql/test/jdbc2/TimestampTest.java2001/09/25 
14:06:33
***
*** 129,132 
--- 129,134 
  
JDBC2Tests.fix(h,  2) + ":" +
  
JDBC2Tests.fix(mn, 2) + ":" +
  
JDBC2Tests.fix(se, 2) + "." +
+ 
+JDBC2Tests.fix(f,  9));
+   }
  }



---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])



Re: [JDBC] driver source code indentation

2001-09-06 Thread Liam Stewart

On Thu, Sep 06, 2001 at 09:51:19AM -0700, Barry Lind wrote:

> Should the jdbc java code use the same formatting as the C code?

IMHO, yes: for consistency and because it is, at the moment, part of the
main "package".

Liam

-- 
Liam Stewart :: Red Hat Canada, Ltd. :: [EMAIL PROTECTED]

---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl



Re: [JDBC] driver source code indentation

2001-09-04 Thread Liam Stewart


On Tue, Sep 04, 2001 at 03:25:33PM -0400, Bruce Momjian wrote:
>   I must say it looks very good.
> 
> Can people tak a look at that and see if they like it?  I will work on
> astyle to find a format that matches the main code indenting.

I like it. The following results in a closer match to the main
PostgreSQL code:

$ astyle --style=java -b -p -j foo.java

I'm in agreement with Barry about using spaces instead of tabs. astyle
does that by default (at least with the java style).

> If you like it, I will indent just after we go beta.

Yes, please.

Liam

-- 
Liam Stewart :: Red Hat Canada, Ltd. :: [EMAIL PROTECTED]

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



[JDBC] driver source code indentation

2001-09-04 Thread Liam Stewart


I suggest that the JDBC driver adopt PostgreSQL's indentation standards 
(see PostgreSQL developers FAQ, question 1). I see that some source
files have used this standard, but the vast majority do not. We should
have a standard for consistency and our own sanity if nothing else.

Liam

-- 
Liam Stewart :: Red Hat Canada, Ltd. :: [EMAIL PROTECTED]

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])



Re: [JDBC] Status of JDBC test suite?

2001-08-29 Thread Liam Stewart

On Wed, Aug 29, 2001 at 08:08:58PM +0200, Anders Bengtsson wrote:

> Actually, we're not talking about Sun's test suite. :-) But now that you
> mention it...

Ok, I see the one that you're talking about. I never knew it was there.
Now to play with it :)

> Could Sun's tests be used as a kind of regression tests as well? Then
> their tests could be the only black-box test suite we'll need!

Ehmm..I've been looking Sun's test suite, but one has to realize that
their test suite is testing for JDBC compliance at the J2EE level, which
is more stringent than normal JDBC 2. It's useful to have, but it's
definately not the only suite we'll need.

> There is already a small unit test suite in the CVS. But it haven't been
> kept up to date with recent changes in the drivers, and it's a bit hard
> to use (thus the need for a how-to).
> The tests use the tool JUnit (http://www.junit.org), that is originally
> intended for one-class-at-a-time testing. On their site is a lot of good
> texts about this kind of unit testing.

I'll take a look at these. Thanks for the pointers,

Liam

-- 
Liam Stewart :: Red Hat Canada, Ltd. :: [EMAIL PROTECTED]

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



Re: [JDBC] Status of JDBC test suite?

2001-08-29 Thread Liam Stewart

On Sun, Aug 26, 2001 at 09:56:09PM +0200, Anders Bengtsson wrote:
> On Sun, 26 Aug 2001, Rene Pijlman wrote:
> 
> > This is probably true, but once you have your environment setup
> > (including a test database, password etc.) its just a matter of
> > typing "make check".
> >
> > Would a brief How-to help?
> 
> Yes! :)

I assume that you're wondering about the JDBC 2 test suite from Sun.
I've attached a note that has some detailed instructions on getting the
suite to work with PostgreSQL. Rene, do you want to post this on your
PostgreSQL JDBC page?

> > >Ideally we should be able to extract parts of the test suite that could be
> > >run without connecting to a backend. It would then be possible to at least
> > >run those parts of the tests in "make".

I think that most, if not all, of the tests in the JDBC suite need to
connect to a database.

> It's not as crazy as it sounds. :-) The driver as a whole must of course
> be tested against a real database. But many of the classes that it is made
> up of could be verified on their own with unit tests. This kind of testing
> catches most of the small "silly" bugs that seem to be the most common
> kind of bug.

Maybe it would be worthwhile to build our own small unit test suite? Can
you explain your idea in more detail?

Liam

-- 
Liam Stewart :: Red Hat Canada, Ltd. :: [EMAIL PROTECTED]



Supplemental instructions for running the JDBC test suite against
PostgreSQL.

1. Configure PostgreSQL so that it accepts TCP/IP connections and
   start the server. Prepare PostgreSQL by creating two users (cts1
   and cts2) and two databases (DB1 and DB2) in the cluster that is
   going to be used for JDBC testing.

2. Download the latest release versions of the J2EE, J2SE, and JDBC
   test suite from Sun's Java site (http://java.sun.com), and install
   according to Sun's documentation.

3. The following environment variables should be set:

  CTS_HOME=
  J2EE_HOME=
  JAVA_HOME=
  NO_JAVATEST=Y
  LOCAL_CLASSES=

4. In $J2EE_HOME/config/default.properties:

  jdbc.drivers=org.postgresql.Driver
  
jdbc.datasources=jdbc/DB1|jdbc:postgresql://localhost:5432/DB1|jdbc/DB2|jdbc:postgresq://localhost:5432/DB2

   Of course, if PostgreSQL is running on a computer different from
   the one running the application server, localhost should be changed
   to the proper host. Also, 5432 should be changed to whatever port
   PostgreSQL is listening on (5432 is the default).

   In $J2EE_HOME/bin/userconfig.sh:

  Add $CTS_HOME/lib/harness.jar, $CTS_HOME/lib/moo.jar,
  $CTS_HOME/lib/util.jar to J2EE_CLASSPATH. Also add the path to
  the PostgreSQL JDBC jar to J2EE_CLASSPATH. Set the JAVA_HOME
  variable to where you installed the J2SE. You should end up with
  something like this:

  CTS_HOME=/home/liams/linux/java/jdbccts
  
J2EE_CLASSPATH=/home/liams/work/inst/postgresql-7.1.2/share/java/postgresql.jar:$CTS_HOME/lib/harness.jar:$CTS_HOME/lib/moo.jar:$CTS_HOME/lib/util.jar
  export J2EE_CLASSPATH

  JAVA_HOME=/home/liams/linux/java/jdk1.3.1
  export JAVA_HOME

   In $CTS_HOME/bin/cts.jte:

  webServerHost=localhost
  webServerPort=8000
  servletServerHost=localhost
  servletServerPort=8000

5. Start the application server (j2ee):

  $ cd $J2EE_HOME
  $ bin/j2ee -verbose

   The server can be stopped after the tests have finished:

 $ cd $J2EE_HOME
 $ bin/j2ee -stop

6. Run the JDBC tests:

 $ cd $CTS_HOME/tests/jdbc/ee
 $ make jdbc-tests



---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



Re: [JDBC] Status of JDBC test suite?

2001-08-29 Thread Liam Stewart

On Sun, Aug 26, 2001 at 09:14:49PM +0200, Rene Pijlman wrote:
> Before I dive into this and fix the test suite, I just wanted to
> check if someone else has already looked into this. Any
> information about the status of the test suite?

Not sure if it's the same thing, but I've noticed that often, the first
time the test harness runs a particular test bucket, most or all of the
tests fail. The second and third passes return work properly (insofar as
there's support in the JDBC driver/PostgreSQL). I haven't had time to
look into it yet.

Liam

-- 
Liam Stewart :: Red Hat Canada, Ltd. :: [EMAIL PROTECTED]

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



Re: [JDBC] Re: Couple of patches for jdbc driver

2001-08-29 Thread Liam Stewart

On Thu, Aug 23, 2001 at 06:42:56PM -0700, Barry Lind wrote:
> So going forward, whose responsibility is it to maintain this file?  Is 
> it the responsibility of the person submitting the patch (i.e. each 
> patch should contain an update to CHANGELOG), or is it the 
> responsibility of the person applying the patch?

I think that whenever a person submits a patch, they should include an
associated changelog entry. It's quite easy to do with emacs (M-x
add-change-log-entry). The CVS commit message can then be taken/adapted
from the changelog patch.

-- 
Liam Stewart :: Red Hat Canada, Ltd. :: [EMAIL PROTECTED]

---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://www.postgresql.org/search.mpl



Re: [JDBC] Unable to connect to database

2001-08-17 Thread Liam Stewart

On Fri, Aug 17, 2001 at 11:00:40AM -0700, Whitney Hunter wrote:

> I believe that the url format is "jdbc.postgresql:///". This
> could be the problem.

Nope, that isn't the problem. The url format is correct. (assuming of
course that the database that Peter is connecting to is running on his
computer on port 5432.)

> I am totally new to both postgresql and jdbc, so I'm probably committing
> some very basic error, but I am unable to make a connection to my
> database via jdbc.  I am using postgresql 7.1.2 which seems to  be
> running OK (under Suse Linux 7.1); at least I can run the sample

Your code looks alright - there are no errors/... there. Try a newer
JDBC driver (from CVS). Other than that, the problem could be your JVM.
Which one are you using exactly?

Liam

-- 
Liam Stewart :: Red Hat Canada, Ltd. :: [EMAIL PROTECTED]

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster



Re: [JDBC] DatabaseMetaData

2001-08-13 Thread Liam Stewart

On Sat, Aug 11, 2001 at 01:13:34AM +0200, Rene Pijlman wrote:
> I'm not sure if this is true. The JDBC book
> (http://java.sun.com/docs/books/jdbc/) says in the description
> of supportsStoredProcedures: "checks whether this database
> supports stored procedure calls using the stored procedure
> escape syntax". And in section A.1.3: "... must be supported by
> a JDBC Compliant driver... Where appropriate, an escape syntax
> must be included for stored procedures, ...". I see no mention
> of J2EE with respect to this requirement.

Ok, I see what you're looking at. However, the book states the escapes
should only be supported when the underlying DBMS supports them and that
escape syntaxes must be included for stored procedures etc where
appropriate. Does PostgreSQL support stored procedures using a stored
procedures escape syntax? If yes, we should return yes, if no, we should
return no until that functionality is added. Both cases are allowed,
AFAICS. The book doesn't mention that drivers should always return true
for this procedure.

> >In general, I think that better checking for
> >unavailable metadata can be done.
> 
> I'm not sure what you mean by that. But maybe I'm the problem,
> its getting late :-)

Actually, I'm not sure what I was saying anymore .. :P never mind this
statement until I figure it out myself :)

> Hmmm... what book are you refering to? I have the "Java 2 EE
> Platform and Components Specifications", but it doesn't have a
> section 6.2.2.3.

"Java 2 EE Specification, v1.2"

Liam

-- 
Liam Stewart :: Red Hat Canada, Ltd. :: [EMAIL PROTECTED]

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster