Обсуждение: newbie: retep wants to have username?
Hello everybody,
I am not that deep in Java, just playing a bit with it, using PG7.1beta from
CVS on RedHat 7.0. Going to contrib/retep/jars I tried:
[mirko@romulan jars]$ java -cp ./retepTools.jar \
uk.org.retep.xml.test.XMLExport \
-Dorg.postgresql.Driver \
-Jjdbc:postgresql:mirko/mirko
Now using JDBC Driver: org.postgresql.Driver
The user property is missing. It is mandatory.
at java.lang.Throwable.<init>(Throwable.java:84)
at java.lang.Exception.<init>(Exception.java:35)
at java.sql.SQLException.<init>(SQLException.java:100)
at org.postgresql.util.PSQLException.<init>(PSQLException.java:23)
at org.postgresql.Connection.openConnection(Connection.java:115)
at org.postgresql.Driver.connect(Driver.java:118)
at java.sql.DriverManager.getConnection(DriverManager.java:523)
at java.sql.DriverManager.getConnection(DriverManager.java:205)
at uk.org.retep.xml.test.XMLExport.<init>(XMLExport.java:55)
at uk.org.retep.xml.test.XMLExport.main(XMLExport.java:186)
[mirko@romulan jars]$
to get a dump of the database. It is a bit of a pity that examples exposed
when invoked without parameters are all about oracle :-).
I tried jdbc:postgresql:mirko/mirko@localhost for -J as well, same result. I
do not see where the jdbc-url is parsed, I guess somewhere in the
pgsql-driver? Is it possible to use a url with user/db@host with PostgreSQL
at all?
I studied the jdbc-interface documentation and did not see this syntax
mentioned anywhere.
Best Regards
Mirko
--
mirko@picard.inka.de
http://sites.inka.de/picard/
Quoting Mirko Zeibig <mirko@picard.inka.de>:
> Hello everybody,
>
> I am not that deep in Java, just playing a bit with it, using PG7.1beta
> from
> CVS on RedHat 7.0. Going to contrib/retep/jars I tried:
>
> [mirko@romulan jars]$ java -cp ./retepTools.jar \
> uk.org.retep.xml.test.XMLExport \
> -Dorg.postgresql.Driver \
> -Jjdbc:postgresql:mirko/mirko
> Now using JDBC Driver: org.postgresql.Driver
> The user property is missing. It is mandatory.
Yes, its asking for the postgresql username.
There's three ways of supplying it.
1: use: .getConnection(url,user,password);
2: use: .getConnection(url) with user/password in the url
3: use: .getConnection(url,props) where props is a Properties with the
user/password in it.
for 2 use: jdbc:postgresql:db?user=PETER&password=SECRET
for 3 have properties called user & password
(internally the driver converts them into Properties anyhow ;-) )
> to get a dump of the database. It is a bit of a pity that examples
> exposed when invoked without parameters are all about oracle :-).
Oracle can be a bit lax with security at times ;-)
> I tried jdbc:postgresql:mirko/mirko@localhost for -J as well, same
Nope. There is no actual url standard (other than jdbc:subprotocol:).
Try: jdbc:postgresql:mirko?user=mirko (localhost is optional or)
jdbc:postgresql://localhost/mirko?user=mirko
> result. I
> do not see where the jdbc-url is parsed, I guess somewhere in the
> pgsql-driver? Is it possible to use a url with user/db@host with
> PostgreSQL
> at all?
>
> I studied the jdbc-interface documentation and did not see this syntax
> mentioned anywhere.
Doesn't exist ;-)
Peter
--
Peter Mount peter@retep.org.uk
PostgreSQL JDBC Driver: http://www.retep.org.uk/postgres/
RetepPDF PDF library for Java: http://www.retep.org.uk/pdf/
On Fri, Feb 16, 2001 at 11:11:58AM -0500, Peter T Mount wrote:
> Quoting Mirko Zeibig <mirko@picard.inka.de>:
> > The user property is missing. It is mandatory.
>
> Yes, its asking for the postgresql username.
>
> There's three ways of supplying it.
>
> 1: use: .getConnection(url,user,password);
> 2: use: .getConnection(url) with user/password in the url
> 3: use: .getConnection(url,props) where props is a Properties with the
> user/password in it.
>
> for 2 use: jdbc:postgresql:db?user=PETER&password=SECRET
>
> for 3 have properties called user & password
>
Thanks a lot! Now I get a connect to the database, but XMLExport is
choking with an error:
[mirko@romulan jars]$ java -cp ./retepTools.jar \
uk.org.retep.xml.test.XMLExport -Dorg.postgresql.Driver \
-J"jdbc:postgresql:mirko?user=mirko&password=XXXXX" -S
Now using JDBC Driver: org.postgresql.Driver
Opened jdbc:postgresql:mirko?user=mirko&password=XXXXX
Generating XML Schema of database
java.lang.NullPointerException
at
org.postgresql.jdbc2.DatabaseMetaData.getTables(DatabaseMetaData.java:1707)
at
uk.org.retep.xml.jdbc.XMLDatabase.writeDatabase(XMLDatabase.java:222)
at
uk.org.retep.xml.jdbc.XMLDatabase.writeDatabase(XMLDatabase.java:188)
at uk.org.retep.xml.test.XMLExport.<init>(XMLExport.java:83)
at uk.org.retep.xml.test.XMLExport.main(XMLExport.java:186)
[mirko@romulan jars]$
If you need more information I am happy to send a more complete transcript
with -verbose enabled.
> >
> > I studied the jdbc-interface documentation and did not see this syntax
> > mentioned anywhere.
>
> Doesn't exist ;-)
Maybe this syntax should be documented anywhere? I knew about 1: but have
not seen 2: or 3: :-).
Best Regards
Mirko
--
mirko@picard.inka.de
http://sites.inka.de/picard/