Обсуждение: jdbc url

Поиск
Список
Период
Сортировка

jdbc url

От
"Marin Dimitrov"
Дата:
hi,

can I pass the username and password for the connection as part of the JDBC
url?

having read some docs it seems that this is not possible, i.e. I can't use
the getConnection(String url) method but I should use the
getConnection(String url, String user, String password) one

thanx,

    Marin

----
"...what you brought from your past, is of no use in your present. When
you must choose a new path, do not bring old experiences with you.
Those who strike out afresh, but who attempt to retain a little of the
old life, end up torn apart by their own memories. "




Re: jdbc url

От
Josh Burdick
Дата:
Marin Dimitrov wrote:

>hi,
>
>can I pass the username and password for the connection as part of the JDBC
>url?
>
>having read some docs it seems that this is not possible, i.e. I can't use
>the getConnection(String url) method but I should use the
>getConnection(String url, String user, String password) one
>

    With the devpgjdbc2 jar, I've been able to use

jdbc:postgresql://linuxmxm/bfdb?user=<username>&password=<password>

(substituting in <username> and <password>.)
    I think I found that from digging through the source.  Don't know
exactly which versions support this, though.  (Also, I'm assuming that
you're using the old-style java.sql.Driver methods, which is what I've
been using.)
    Josh

>
>thanx,
>
>    Marin
>
>----
>"...what you brought from your past, is of no use in your present. When
>you must choose a new path, do not bring old experiences with you.
>Those who strike out afresh, but who attempt to retain a little of the
>old life, end up torn apart by their own memories. "
>
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: you can get off all lists at once with the unregister command
>    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
>
--
Josh Burdick
jburdick@gradient.cis.upenn.edu
http://www.cis.upenn.edu/~jburdick



Strange timezone issue on Freebsd

От
"Jan Aleman"
Дата:
Strange timezone issue on Freebsd

Setup:

FreeBSD 4.5
JDK 1.4 (linux port)
Postgresql: 7.1
Timezone on server: CET (GMT+1)
(additionally also TZ=CET in environment)

TABLE:

                 Table "supplier_avail"
     Attribute     |           Type           | Modifier
-------------------+--------------------------+----------
 supplier_avail_id | integer                  | not null
 supplier_id       | integer                  | not null
 weekday           | integer                  | not null
 start_time        | timestamp with time zone |
 end_time          | timestamp with time zone |
Index: supplier_avail_pkey

The query (when executed from psql):

SELECT MIN(start_time) from supplier_avail where supplier_id = 1023 and
weekday = 2

Returns:

2001-01-01 09:00:00+01

Now the problem:
Consider the following Java snippet:

IContentList openCL = cm.getContentByQuery(
                " SELECT"+
                " MIN(start_time)"+
                " from supplier_avail where supplier_id =
"+supplier_id+" and weekday = "+weekday,1);
out.print(openCL.getValueAt(0,0));

returns:
2001-01-01 08:00:00.0

The funny thing is if I connect from my Windows XP machine (Timezone
also at GMT +1) the time I really want (09:00) is returned.

I have scanned through the docs but was unable to find out if I'm doing
something wrong.

Thanks for helping me out

Jan Aleman


Re: Strange timezone issue on Freebsd

От
"Jan Aleman"
Дата:
I've just found the solution for this, not sure why but the JDK 1.4 does
by default not use the system's timezone.

By starting java with -Duser.timezone=CET I fixed this issue.


Jan Aleman

> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Jan Aleman
> Sent: Monday, March 18, 2002 9:22 PM
> To: 'pgsql-jdbc'
> Subject: [JDBC] Strange timezone issue on Freebsd
>
>
> Strange timezone issue on Freebsd
>
> Setup:
>
> FreeBSD 4.5
> JDK 1.4 (linux port)
> Postgresql: 7.1
> Timezone on server: CET (GMT+1)
> (additionally also TZ=CET in environment)
>
> TABLE:
>
>                  Table "supplier_avail"
>      Attribute     |           Type           | Modifier
> -------------------+--------------------------+----------
>  supplier_avail_id | integer                  | not null
>  supplier_id       | integer                  | not null
>  weekday           | integer                  | not null
>  start_time        | timestamp with time zone |
>  end_time          | timestamp with time zone |
> Index: supplier_avail_pkey
>
> The query (when executed from psql):
>
> SELECT MIN(start_time) from supplier_avail where supplier_id
> = 1023 and weekday = 2
>
> Returns:
>
> 2001-01-01 09:00:00+01
>
> Now the problem:
> Consider the following Java snippet:
>
> IContentList openCL = cm.getContentByQuery(
>                 " SELECT"+
>                 " MIN(start_time)"+
>                 " from supplier_avail where supplier_id =
> "+supplier_id+" and weekday = "+weekday,1);
> out.print(openCL.getValueAt(0,0));
>
> returns:
> 2001-01-01 08:00:00.0
>
> The funny thing is if I connect from my Windows XP machine
> (Timezone also at GMT +1) the time I really want (09:00) is returned.
>
> I have scanned through the docs but was unable to find out if
> I'm doing something wrong.
>
> Thanks for helping me out
>
> Jan Aleman
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to
> majordomo@postgresql.org
>