[JDBC] How to encode and decode a string as a password field in pgsql table?

2001-05-03 Thread Subhramanya Shiva

hi all

How to encrypt and decrypt a value which is kept as a password in a table.
In mysql we r having encode and decode ... but in pgsql how to do this using
Java.

regards
Shiva.


-- 
Subhramanya Shiva, Programmer
Archean InfoTech pvt.Ltd.
Hyderabad, India
http://www.archeanit.com



---(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



Re: [JDBC] Re: Unable to store SHA hash (Non-HTML--Sorry)

2001-05-03 Thread David Wall

> In my code where I need to store short pieces of binary data (like
> digests) I encode them in hex and store the hex.  Yes this results in a
> 2 times increase in storage, and some overhead in encoding/decodeing,
> but it isn't too bad.  Sure you could use other encodings for the binary
> data, but I find hex to be the easiest for small amounts of data.

We use base64 which converts every 3 characters into 4 (as I recall) for
such short things.  For longer, type oid in sql works with
setBytes()/getBytes() in JDBC2, but what the overhead is for a small amount
of binary data I don't know.

David


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

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



[JDBC] Re: Unable to store SHA hash (Non-HTML--Sorry)

2001-05-03 Thread Barry Lind

Jerry,

There are a couple of things going on here.  First you really can't use 
a postgres char/varchar/text datatype to store/retrieve binary 
information with jdbc.  (See a message I just posted to the jdbc mail 
list explaining character set conversions in the 7.1 jdbc drivers).

So the proper datatype for binary information in Postgres is the 'bytea' 
type.  Unfortunately there isn't any support in the jdbc drivers for 
this datatype (anyone want to contribute a fix???), so you really can't 
use that in your situation either.

In my code where I need to store short pieces of binary data (like 
digests) I encode them in hex and store the hex.  Yes this results in a 
2 times increase in storage, and some overhead in encoding/decodeing, 
but it isn't too bad.  Sure you could use other encodings for the binary 
data, but I find hex to be the easiest for small amounts of data.

thanks,
--Barry

Jerry Reid wrote:

> I apologize if this message appears in duplicate. The original was 
> posted before the I received notice that an additional confirmation 
> message would be needed to get onto the list.
> 
> I recently migrated an application from Oracle to Postgresql 7.1. The
> migration was fairly painless with one exception:
> 
> User's passwords are hashed using SHA, then stored in the database. Ie.
>// Get the hash of the password
>MessageDigest md=null;
>try {
>  md = MessageDigest.getInstance("sha");
>}
>catch (NoSuchAlgorithmException e) {
>  System.out.println("Error: sha encryption unavailable.");
>}
>String hashedPass = new
> String(md.digest(request.getParameter("pass").getBytes()));
> 
> This string contains several characters that are outside the normal ASCII
> range. The string could be stored and retrieved using Oracle and 
> MySQL, but
> in Postgres any unusual characters become '?'. This corrupts the hash and
> prevents users from logging on.
> So far, the following have been tried:
> - Password stored using PreparedStatement setString() call. Retrieved 
> using
> ResultSet.getString(). Verified hash corruption in the database.
> - Password field datatype changed from varchar to bytea. Oddly enough,
> PreparedStatement.setBytes() can not be used against this datatype. 
> Resorted
> to using .setString(). Hash was still corrupted at the database level.
> 
> Any insight into how to accomplish this task would be greatly 
> appreciated.
> 
> Jerry
> 
> 
> 
> _
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
> 
> 
> ---(end of broadcast)---
> TIP 4: Don't 'kill -9' the postmaster
> 
> 


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



[JDBC] Re: A bug with pgsql 7.1/jdbc and non-ascii (8-bit) chars?

2001-05-03 Thread Barry Lind

Since Java uses unicode (ucs2) internally for all Strings, the jdbc code 
always needs to do character set conversions for all strings it gets 
from the database.  In the 7.0 drivers this was done by assuming the 
database was using the same character set as the default on the client, 
which is incorrect for a number of reasons.  In 7.1 the jdbc code asks 
the database what character set it is using and does the conversion from 
the server character set to the java unicode strings.

Now it turns out that Postgres is a little lax in its character set 
support, so you can very easily insert char/varchar/text with values 
that fall outside the range of valid values for a given character set 
(and psql doesn't really care either).  However in java since we must do 
character set conversion to unicode, it does make a difference and any 
values that were inserted that are incorrect with regards to the 
database character set will be reported as ?'s in java.

With regards to your specific problem, my guess is that you haven't 
created you database with the proper character set for the data you are 
storing in it.  I am guessing you simply used the default SQL Acsii 
character set for your created database and therefore only the first 127 
characters are defined.  Any characters above 127 will be returned by 
java as ?'s.

If this is the case you will need to recreate your database with the 
proper character set for the data you are storing in it and then 
everything should be fine.

thanks,
--Barry

Jani Averbach wrote:

> Hi!
>  
> I have a problem like that:
>  
> Environment:
>  
> The database is postgresql v7.1, with locale-support
> jdk is sun's jdk1.3.0_02
> and jdbc is that one which comes with postgres (type 2).
>  
> Both database and jdbc driver has been build by myself.
>  
> OS: RH 6.2 based linux with 2.4.3 kernel, glibc 2.1.3.
>  
> The problem:
>  
> There is a database which contains fields (the field's type is 'text')
> with scandinavian alphabet. (Especially ÖÄÅöäå (odiaeresis, adiaeresis,
> aring, or in other words, oe, ae, and a with ring above it)).
> 
> 
> The database has been installed, created and used under
> LC_ALL="finnish" and LANG="fi_FI" environment variables in act.
>  
> Ok, the problem:
> 
> When I try to read those field, I get guestion marks instead of those
> 8-bit scandic chars. 
> 
> I have been check my java programs and the database. (in fact, same
> problem appears with postgres-7.1/src/interfaces/jdbc/example/psql.java).
> In general, my java environment works fine with 8-bit chars, with psgl
> (not the java one) there is everything very well with those fields with
> 8-bit chars.
> 
> So my question is, am I doing something wrong, or is there a bug in the
> pgsql-jdbc? 
> 
> If this is a bug or you need otherwise help or more information, please
> let me know. I will try to help as much as possible to hunt this one
> down.
> 
> If I am doing something stupid, I would very likely to know it...
> 
> BR, Jani
> 
> ---
> Jani Averbach 
> 
> 
> 
> 
> ---(end of broadcast)---
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 
> 


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

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



[JDBC] Bug-report (was: JDBC driver in pgsql 7.1 build problem)

2001-05-03 Thread Rolf Schillinger

Hi again,
it`s now offical, I found a bug in JDBC driver in pgsql 7.1 ;)
I had the following problems:
/usr/local/jakarta-ant-1.3/bin//ant -buildfile ../../../build.xml
-Dmajor=7 -Dminor=1 -Dfullversion=7.1 -Ddef_pgport=5432
Buildfile: ../../../build.xml

jar:

call:

prepare:

check_versions:

driver:
 [echo] Configured build for the JDBC2 edition driver.

compile:
[javac] Compiling 41 source files to
/usr/src/postgresql-7.1/src/interfaces/jdbc/build
[javac]
/usr/src/postgresql-7.1/src/interfaces/jdbc/org/postgresql/Driver.java:199: ';'
expected
[javac] return ${major};
[javac] ^
[javac]
/usr/src/postgresql-7.1/src/interfaces/jdbc/org/postgresql/Driver.java:209: ';'
expected
[javac] return ${minor};
[javac] ^
[javac]
/usr/src/postgresql-7.1/src/interfaces/jdbc/org/postgresql/Driver.java:199: cannot
resolve symbol
[javac] symbol  : variable $  
[javac] location: class org.postgresql.Driver
[javac] return ${major};
[javac]^
[javac]
/usr/src/postgresql-7.1/src/interfaces/jdbc/org/postgresql/Driver.java:209: cannot
resolve symbol
[javac] symbol  : variable $  
[javac] location: class org.postgresql.Driver
[javac] return ${minor};
[javac]^
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -deprecation for details.
[javac] 4 errors

BUILD FAILED

/usr/src/postgresql-7.1/src/interfaces/jdbc/build.xml:99: Compile failed,
messages should have been provided.

Total time: 9 seconds
make: *** [all] Error 1

when using 
JDK:
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build
Blackdown-1.3.0-RC1)
Java HotSpot(TM) Client VM (build Blackdown-1.3.0-RC1, mixed mode)

Ant:
Ant version 1.3 compiled on March 2 2001

Postgresql:
As stated above: 7.1

the following patch by Marko Kreen <[EMAIL PROTECTED]> solved that problem:
http://www.l-t.ee/marko/pgsql/ant12.diff

Again thanks for all the help on this friendly list :)
bis bald, Rolf



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



[JDBC] Updateable ResultSet

2001-05-03 Thread Mike D'Agosta

Hello,

I am brand new to this list. I looked through the mailing list archive, 
but couldn't determine if ResultSets are Updateable yet. I'm using some old 
drivers for pgsql-jdbc. Are there drivers out now that have Updateable 
ResultSets?

Thanks!
Mike


---(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



Re: [JDBC] Returning oid or primary key

2001-05-03 Thread Bruce Momjian

-- Start of PGP signed section.
> > From: Bruce Momjian <[EMAIL PROTECTED]>
> > Date: Thu, 3 May 2001 13:42:23 -0400 (EDT)
>  
> > Certainly the portable solution is to get RETURNING into the backend so
> > you can decide what you want to return.
> 
> I agree.  Is that currently planned for the next release?

I don't know.  That is the problem.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 853-3000
  +  If your life is a hard drive, |  830 Blythe Avenue
  +  Christ can be your backup.|  Drexel Hill, Pennsylvania 19026

---(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] multiple resource sets

2001-05-03 Thread Rolf Schillinger

Hi Dave,
Thanks for helping me but this post was kinda runaway. I thought it didn`t
get through at first, forgot about it and tried upgrading the JDBC driver.
After doing this now all of that stuff works. So it was an error in the
JDBC driver :)
bis bald, Rolf

On Thu, 3 May 2001, Dave Cramer wrote:

> Rolf,
> 
> 
> Try this
> 
> ResultSet orderlines = _st.executeQuery();
> 
> while(orderlines.next()){
>  println(orderlines.get(1));
> }
> orderlines.close();
> _st.close();
> 
> Dave
> - Original Message - 
> From: "Rolf Schillinger" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, May 02, 2001 10:12 AM
> Subject: [JDBC] multiple resource sets
> 
> 
> > Hi,
> > I`m having huge troubles using postgresql JDBC.
> > I do the following:
> > while (orderlines.next())
> > {
> > PreparedStatement as_st=db.prepareStatement("SELECT nr,beschreibung,
> > beschreibung_2,preis FROM artikel where nr=?");
> > System.out.println(orderlines.getRow()+" : "+orderlines.getString(2));
> > }
> > As result I get:
> > 1 : KKSC025
> > 2 : KKTO045
> > which is totally okay cause the underlying table data is as follows:
> >  id |   nr| anzahl | eht 
> > +-++-
> >  1226969416 | KKSC025 | 22 | BU1
> >  1226969416 | KKTO045 | 22 | KT
> > 
> > So far so good.
> > I know want to process the results of that orderlines query by adding:
> > as_st.setString(1,orderlines.getString(2));
> > as=as_st.executeQuery();
> > as.close();
> > to the above while loop.
> > Output now looks like:
> > 1 : KKSC025
> > 2 : Nalo schmal 45/50 rauchbraun
> > 1) is still correct while 2) has the value of as_st/as now.
> > I`m getting desperate on that.
> > any help would be greatly appreciated.
> > thanks, Rolf
> > 
> > 
> > 
> > 
> > ---(end of broadcast)---
> > TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
> > 
> > 
> 
> 


---(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



[JDBC] A bug with pgsql 7.1/jdbc and non-ascii (8-bit) chars?

2001-05-03 Thread Jani Averbach


Hi!
 
I have a problem like that:
 
Environment:
 
The database is postgresql v7.1, with locale-support
jdk is sun's jdk1.3.0_02
and jdbc is that one which comes with postgres (type 2).
 
Both database and jdbc driver has been build by myself.
 
OS: RH 6.2 based linux with 2.4.3 kernel, glibc 2.1.3.
 
The problem:
 
There is a database which contains fields (the field's type is 'text')
with scandinavian alphabet. (Especially ÖÄÅöäå (odiaeresis, adiaeresis,
aring, or in other words, oe, ae, and a with ring above it)).


The database has been installed, created and used under
LC_ALL="finnish" and LANG="fi_FI" environment variables in act.
 
Ok, the problem:

When I try to read those field, I get guestion marks instead of those
8-bit scandic chars. 

I have been check my java programs and the database. (in fact, same
problem appears with postgres-7.1/src/interfaces/jdbc/example/psql.java).
In general, my java environment works fine with 8-bit chars, with psgl
(not the java one) there is everything very well with those fields with
8-bit chars.

So my question is, am I doing something wrong, or is there a bug in the
pgsql-jdbc? 

If this is a bug or you need otherwise help or more information, please
let me know. I will try to help as much as possible to hunt this one
down.

If I am doing something stupid, I would very likely to know it...

BR, Jani

---
Jani Averbach 




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

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



Re: [JDBC] Returning oid or primary key

2001-05-03 Thread Ned Wolpert

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

> From: Bruce Momjian <[EMAIL PROTECTED]>
> Date: Thu, 3 May 2001 13:42:23 -0400 (EDT)
 
> Certainly the portable solution is to get RETURNING into the backend so
> you can decide what you want to return.

I agree.  Is that currently planned for the next release?

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: Public key at http://www.keyserver.net

iD8DBQE68ZjfiysnOdCML0URAnAkAJ4h2r21+uvdZzw14Prmy8SgvqJs2QCeMMN8
YpwRmYJkfJdzZnkpqTLfI3Q=
=PqCG
-END PGP SIGNATURE-

-- 
Virtually, 
Ned Wolpert <[EMAIL PROTECTED]>

D08C2F45:  28E7 56CB 58AC C622 5A51  3C42 8B2B 2739 D08C 2F45 


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

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



Re: [JDBC] multiple resource sets

2001-05-03 Thread Dave Cramer

Rolf,


Try this

ResultSet orderlines = _st.executeQuery();

while(orderlines.next()){
 println(orderlines.get(1));
}
orderlines.close();
_st.close();

Dave
- Original Message - 
From: "Rolf Schillinger" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 02, 2001 10:12 AM
Subject: [JDBC] multiple resource sets


> Hi,
> I`m having huge troubles using postgresql JDBC.
> I do the following:
> while (orderlines.next())
> {
> PreparedStatement as_st=db.prepareStatement("SELECT nr,beschreibung,
> beschreibung_2,preis FROM artikel where nr=?");
> System.out.println(orderlines.getRow()+" : "+orderlines.getString(2));
> }
> As result I get:
> 1 : KKSC025
> 2 : KKTO045
> which is totally okay cause the underlying table data is as follows:
>  id |   nr| anzahl | eht 
> +-++-
>  1226969416 | KKSC025 | 22 | BU1
>  1226969416 | KKTO045 | 22 | KT
> 
> So far so good.
> I know want to process the results of that orderlines query by adding:
> as_st.setString(1,orderlines.getString(2));
> as=as_st.executeQuery();
> as.close();
> to the above while loop.
> Output now looks like:
> 1 : KKSC025
> 2 : Nalo schmal 45/50 rauchbraun
> 1) is still correct while 2) has the value of as_st/as now.
> I`m getting desperate on that.
> any help would be greatly appreciated.
> thanks, Rolf
> 
> 
> 
> 
> ---(end of broadcast)---
> TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
> 
> 


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



Re: [JDBC] Returning oid or primary key

2001-05-03 Thread Bruce Momjian

> However, _if_ RETURNING is going to be in the standard SQL for the
> next release, _and_ there are plans to update the jdbc driver to take
> advantage of that in the callable statement, as well, then it makes
> more sense _not_ to add my patch that implements the 'overloading' of
> the return value in the jdbc driver.
> 
> I guess the issue is the ability to return the primary key from an
> inserted row, for cases that it's auto-generated, such as using the
> serial type.

Certainly the portable solution is to get RETURNING into the backend so
you can decide what you want to return.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 853-3000
  +  If your life is a hard drive, |  830 Blythe Avenue
  +  Christ can be your backup.|  Drexel Hill, Pennsylvania 19026

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



[JDBC] Unable to store SHA hash

2001-05-03 Thread Jerry Reid

I recently migrated an application from Oracle to Postgresql 7.1. The 
migration was fairly painless with one exception:

User's passwords are hashed using SHA, then stored in the database. Ie.
// Get the hash of the password
MessageDigest md=null;
try {
  md = MessageDigest.getInstance("sha");
}
catch (NoSuchAlgorithmException e) {
  System.out.println("Error: sha encryption unavailable.");
}
String hashedPass = new 
String(md.digest(request.getParameter("pass").getBytes()));

This string contains several characters that are outside the normal ASCII 
range. The string could be stored and retrieved using Oracle and MySQL, but 
in Postgres any unusual characters become '?'. This corrupts the hash and 
prevents users from logging on.

So far, the following have been tried:
- Password stored using PreparedStatement setString() call. Retrieved using 
ResultSet(). Verified hash corruption in the database.
- Password field datatype changed from varchar to bytea. Oddly enough, 
PreparedStatement.setBytes() can not be used against this datatype. Resorted 
to using .setString(). Hash was still corrupted at the database level.

Any insight into how to accomplish this task would be greatly appreciated.

Jerry
_
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


---(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



[JDBC] A bug fix for JDBC's getTables() in Postgresql 7.1

2001-05-03 Thread Panu Outinen

Hi !!

I was trying to get a very nice FREE graphical db tool called DbVisualizer 
(http://www.ideit.com/products/dbvis/) to work with Postgresql and I found 
out the following bug: if database has views then getTables() gets the null 
pointer exception ('order by relname' makes the listing tree in 
DbVisualizer a lot useful !!)

This patch should propably be applied to the the jdbc1's 
DatabaseMetaData.java, too.

[/tmp/postgresql-7.1/src/interfaces/jdbc/org/postgresql/jdbc2]$
http://www.ideit.com/products/dbvis/

...

DbVisualizer
Version: 2.0
Released: 2001-04-20


The #1 requested feature to ease editing table data is now supported!
The #2 requested feature to print graphs is now supported!
Read the complete change log for all new features and enhancements!


DbVisualizer is a cross platform database visualization and edit tool 
relying 100% on the JDBC, Java Database Connectivity API's. DbVisualizer 
enables simultaneous connections to many different databases through JDBC 
drivers available from a variety of vendors. Just point and click to browse 
the structure of the database, characteristics of tables, etc. No matter if 
it's an enterprise database from Oracle or an open source product like 
InstantDB!

And best of all -> it's FREE!
-



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



Re: [JDBC] Returning oid or primary key

2001-05-03 Thread Bruce Momjian

-- Start of PGP signed section.
> (If this is the second time you've seen this message, sorry about that...
> it didn't seem to go through the first time I sent it.)
> 
> 
> Folks-
> 
>   I've got an idea on a possible extension to the jdbc driver.  I want
> to submit a patch, but only if others think it makes sense.  I want to
> add a 'clause' that would slightly change the return value of the
> executeUpdate(String) method in the Statment class.  The goal is to
> allow the return of the oid instead of the number of rows affected in
> certain cases.  For example:
> 
>   insert into tablename(name) values('sample') returning oid
> 
> as the string would cause the returning value of the executeUpdate()
> method to be the oid of inserted row (if successful) instead of the
> count of updated rows.
> 
> I like the idea since I can now use standard pooling managers (like
> PoolMan) and have access to the oid without having access to the
> postgresql Statement class.  Of course, the problem is that I'm now
> 'overloading' the returning value of the method, which is ugly.  Also,
> 'faking' SQL syntax in the jdbc driver that doesn't exist in the
> postgresql backend may also be problematic.  Since callable statement
> doesn't support returned values yet, I figure this would help.

So you really want the OID from the update?  We want to add RETURNING to
the standard SQL capabilities of the backend.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 853-3000
  +  If your life is a hard drive, |  830 Blythe Avenue
  +  Christ can be your backup.|  Drexel Hill, Pennsylvania 19026

---(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] Returning oid or primary key

2001-05-03 Thread Ned Wolpert

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

> From: Bruce Momjian <[EMAIL PROTECTED]>
> Date: Thu, 3 May 2001 13:29:55 -0400 (EDT)

> >   insert into tablename(name) values('sample') returning oid
> > 
> > as the string would cause the returning value of the executeUpdate()
> > method to be the oid of inserted row (if successful) instead of the
> > count of updated rows.
> > 

> So you really want the OID from the update?  We want to add RETURNING to
> the standard SQL capabilities of the backend. 

Well... I want the oid from the update, but also the ability to use
Callable Statement to get the primary key as well.  

The issue is the ability to find the generated index for the row
easilly with jdbc, without having to figure out if I'm using the
org.postgresql.Statement class.  (Which with some pool managers, isn't
directly available.)  I can use the OID to find the row just inserted,
and then lookup the generated index.  If the callable statement could
return a value, then it's easy.  But the class isn't really
implemented for that in the current postgresql jdbc driver.  I figure
that until RETURNING is added to the backend, and callable statement
works, this would be an 'ok' workaround.  Not a great workaround,
since I don't like 'overloading' a return value, especially in Java.

However, _if_ RETURNING is going to be in the standard SQL for the
next release, _and_ there are plans to update the jdbc driver to take
advantage of that in the callable statement, as well, then it makes
more sense _not_ to add my patch that implements the 'overloading' of
the return value in the jdbc driver.

I guess the issue is the ability to return the primary key from an
inserted row, for cases that it's auto-generated, such as using the
serial type.

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: Public key at http://www.keyserver.net

iD8DBQE68ZgJiysnOdCML0URAkyZAJ9+dW+SSsYf0E0i2IthciFbj/tojACeIHyF
47YW7+yMta3wFs1loosfEfw=
=j1lP
-END PGP SIGNATURE-

-- 
Virtually, 
Ned Wolpert <[EMAIL PROTECTED]>

D08C2F45:  28E7 56CB 58AC C622 5A51  3C42 8B2B 2739 D08C 2F45 


---(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



[JDBC] multiple resource sets

2001-05-03 Thread Rolf Schillinger

Hi,
I`m having huge troubles using postgresql JDBC.
I do the following:
while (orderlines.next())
{
PreparedStatement as_st=db.prepareStatement("SELECT nr,beschreibung,
beschreibung_2,preis FROM artikel where nr=?");
System.out.println(orderlines.getRow()+" : "+orderlines.getString(2));
}
As result I get:
1 : KKSC025
2 : KKTO045
which is totally okay cause the underlying table data is as follows:
 id |   nr| anzahl | eht 
+-++-
 1226969416 | KKSC025 | 22 | BU1
 1226969416 | KKTO045 | 22 | KT

So far so good.
I know want to process the results of that orderlines query by adding:
as_st.setString(1,orderlines.getString(2));
as=as_st.executeQuery();
as.close();
to the above while loop.
Output now looks like:
1 : KKSC025
2 : Nalo schmal 45/50 rauchbraun
1) is still correct while 2) has the value of as_st/as now.
I`m getting desperate on that.
any help would be greatly appreciated.
thanks, Rolf




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



[JDBC] Returning oid or primary key

2001-05-03 Thread Ned Wolpert

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

(If this is the second time you've seen this message, sorry about that...
it didn't seem to go through the first time I sent it.)


Folks-

  I've got an idea on a possible extension to the jdbc driver.  I want
to submit a patch, but only if others think it makes sense.  I want to
add a 'clause' that would slightly change the return value of the
executeUpdate(String) method in the Statment class.  The goal is to
allow the return of the oid instead of the number of rows affected in
certain cases.  For example:

  insert into tablename(name) values('sample') returning oid

as the string would cause the returning value of the executeUpdate()
method to be the oid of inserted row (if successful) instead of the
count of updated rows.

I like the idea since I can now use standard pooling managers (like
PoolMan) and have access to the oid without having access to the
postgresql Statement class.  Of course, the problem is that I'm now
'overloading' the returning value of the method, which is ugly.  Also,
'faking' SQL syntax in the jdbc driver that doesn't exist in the
postgresql backend may also be problematic.  Since callable statement
doesn't support returned values yet, I figure this would help.

What are people's thoughts about this?
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: Public key at http://www.keyserver.net

iD8DBQE68X3PiysnOdCML0URAlrxAJ90YtoR1lPGjeDGXJulXcJtS5aslACaArqq
/oGoNBmIRVx8gOn+PRy+rLY=
=Uiae
-END PGP SIGNATURE-

-- 
Virtually, 
Ned Wolpert <[EMAIL PROTECTED]>

D08C2F45:  28E7 56CB 58AC C622 5A51  3C42 8B2B 2739 D08C 2F45 


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



[JDBC] accessing arrays

2001-05-03 Thread Seth Milder

Hi there,

I was wondering if anyone knows how to access an integer array of 
variable length with JDBC. I mean like this:


create table ( foo int4[]);

The insertion is easy, but what method would I use to get this field 
from a result set? I am sorry if this is a stupid question, but I am new 
to all this.

Thanks,

Seth


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

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



Re: [JDBC] JDBC driver in pgsql 7.1 build problem

2001-05-03 Thread Marko Kreen

On Thu, May 03, 2001 at 11:35:23AM +0200, Rolf Schillinger wrote:
> Hi,
> I have strange problems trying to build the JDBC driver for postgresql
> 7.1:

try this patch:

  http://www.l-t.ee/marko/pgsql/ant12.diff

then 'make clean', 'make'

-- 
marko


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

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



[JDBC] JDBC driver in pgsql 7.1 build problem

2001-05-03 Thread Rolf Schillinger

Hi,
I have strange problems trying to build the JDBC driver for postgresql
7.1:
/usr/local/jakarta-ant-1.3/bin//ant -buildfile ../../../build.xml
-Dmajor=7 -Dminor=1 -Dfullversion=7.1 -Ddef_pgport=5432
Buildfile: ../../../build.xml

jar:

call:

prepare:

check_versions:

driver:
 [echo] Configured build for the JDBC2 edition driver.

compile:
[javac] Compiling 41 source files to
/usr/src/postgresql-7.1/src/interfaces/jdbc/build
[javac]
/usr/src/postgresql-7.1/src/interfaces/jdbc/org/postgresql/Driver.java:199: ';'
expected
[javac] return ${major};
[javac] ^
[javac]
/usr/src/postgresql-7.1/src/interfaces/jdbc/org/postgresql/Driver.java:209: ';'
expected
[javac] return ${minor};
[javac] ^
[javac]
/usr/src/postgresql-7.1/src/interfaces/jdbc/org/postgresql/Driver.java:199: cannot
resolve symbol
[javac] symbol  : variable $  
[javac] location: class org.postgresql.Driver
[javac] return ${major};
[javac]^
[javac]
/usr/src/postgresql-7.1/src/interfaces/jdbc/org/postgresql/Driver.java:209: cannot
resolve symbol
[javac] symbol  : variable $  
[javac] location: class org.postgresql.Driver
[javac] return ${minor};
[javac]^
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -deprecation for details.
[javac] 4 errors

BUILD FAILED

/usr/src/postgresql-7.1/src/interfaces/jdbc/build.xml:99: Compile failed,
messages should have been provided.

Total time: 9 seconds
make: *** [all] Error 1

Any help would be greatly appreciated
bis bald, Rolf


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