Re: [JDBC] JDBC 2 ResultSet and cursors
To use a cursor behind the scenes would require the jdbc driver to have its own begin/end block. Because the connection is shared, there is nothing that prevents someone else from trying to execute a begin/end/commit/rollback statement that would screw up the driver. So it would need a seperate connection for each scrollable resultset. Kovcs Pter wrote: I am afraid I do not understand your explanation. What do you mean by "begin/end block"? I am thinking in terms of simple SQL statements like: begin; declare myc cursor for select * from mm_history; fetch forward 2 in myc; close myc; rollback; (or if you did some update in the same transaction: commit;) -Original Message----- From: Joseph Shraibman [mailto:[EMAIL PROTECTED]] Sent: Tuesday, October 16, 2001 11:54 PM To: Kovcs Pter Cc: [EMAIL PROTECTED] Subject: Re: JDBC 2 ResultSet and cursors Because the driver would have to dedicate a connection to the backend to the resultset to make sure nobody else tries to begin/end a block while it is trying to use a cursor. (that's the simple explanation) Since a connection to the backend currently requires a fork, it would be a real resource hog. Kovcs Pter wrote: Hi, I have a question for which I can think of an answer, but still I am uncertain about it. Why the scrollable result sets are not implemented in the current jdbc driver? Is it technically impossible or just no one needed this feature yet? The answer is probably that due to the lack of backend support for updatable cursors the scrollable result set would not be fully functional. (On the face of it, I think that it should be possible to build support for read-only scrollable result set into the jdbc driver.) But would a halfway solution not be better than nothing? You need to resort to workarounds anyway, if you want to use cursor based data processing with PostgreSQL. IMHO, a read-only scrollable result set would definitly be an important step toward code portability. Any comments? Does anyone have info on whether there are plans to implement support for updatable cursors in the backend? If there are, what are they? Thank you Peter ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED]) -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [JDBC] J2SE 1.4 and other patches
Don't you need execute cvs commands to add new files? I guess I don't know. Barry Lind wrote: Anyone can do that by submitting a patch. I don't see anything special that needs to be done. --Barry Joseph Shraibman wrote: Right. And a maintainer needs to make a jdbc3 direcotry and modifiy the ant files to use it when it detects a jdk of 1.4+ Dave Cramer wrote: What do you see wrong with the build process? Ant is used to build the driver! Dave -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Joseph Shraibman Sent: October 16, 2001 5:45 PM To: Rene Pijlman Cc: Mark Lillywhite (pg-jdbc); [EMAIL PROTECTED] Subject: Re: [JDBC] J2SE 1.4 and other patches I think what most needs to be done is for someone to update the build process, so people who want to hack code will have somewhere to start from. Rene Pijlman wrote: On 13 Oct 2001 11:16:07 +1000, you wrote: I was just wondering if anyone is working on support for JDK1.4 for the postgresql drivers. Not AFAIK. It appears that there are some new methods defined in a few interfaces that need to be implemented (presumably to just throw the unimplemented exception?). Do you mean JDBC 3.0 methods? What methods precisely? Are they implementable? Also, I have a patch for DatabaseMetaData to fix a bug in the metadata returned for BigDecimals. I have already tried to submit this patch 2 or 3 times (to peter@retep) but never heard back. It's only about 4 LOC but it makes introspecting the database much better. Is this the place to post a patch, and if I do, am I likely to get a response? You can send patches to the [EMAIL PROTECTED] list, preferably with a CC to this list. Yes, you will get a response. Usually, a patch is applied within a week (if the patch is good, of course). If a patch to the JDBC driver needs discussion first, that should be on this list. Regards, René Pijlman [EMAIL PROTECTED] ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [JDBC] J2SE 1.4 and other patches
FYI To see what's new: http://java.sun.com/j2se/1.4/docs/relnotes/features.html#jdbc -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
Re: [JDBC] J2SE 1.4 and other patches
Right. And a maintainer needs to make a jdbc3 direcotry and modifiy the ant files to use it when it detects a jdk of 1.4+ Dave Cramer wrote: What do you see wrong with the build process? Ant is used to build the driver! Dave -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Joseph Shraibman Sent: October 16, 2001 5:45 PM To: Rene Pijlman Cc: Mark Lillywhite (pg-jdbc); [EMAIL PROTECTED] Subject: Re: [JDBC] J2SE 1.4 and other patches I think what most needs to be done is for someone to update the build process, so people who want to hack code will have somewhere to start from. Rene Pijlman wrote: On 13 Oct 2001 11:16:07 +1000, you wrote: I was just wondering if anyone is working on support for JDK1.4 for the postgresql drivers. Not AFAIK. It appears that there are some new methods defined in a few interfaces that need to be implemented (presumably to just throw the unimplemented exception?). Do you mean JDBC 3.0 methods? What methods precisely? Are they implementable? Also, I have a patch for DatabaseMetaData to fix a bug in the metadata returned for BigDecimals. I have already tried to submit this patch 2 or 3 times (to peter@retep) but never heard back. It's only about 4 LOC but it makes introspecting the database much better. Is this the place to post a patch, and if I do, am I likely to get a response? You can send patches to the [EMAIL PROTECTED] list, preferably with a CC to this list. Yes, you will get a response. Usually, a patch is applied within a week (if the patch is good, of course). If a patch to the JDBC driver needs discussion first, that should be on this list. Regards, René Pijlman [EMAIL PROTECTED] ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [JDBC] J2SE 1.4 and other patches
I think what most needs to be done is for someone to update the build process, so people who want to hack code will have somewhere to start from. Rene Pijlman wrote: On 13 Oct 2001 11:16:07 +1000, you wrote: I was just wondering if anyone is working on support for JDK1.4 for the postgresql drivers. Not AFAIK. It appears that there are some new methods defined in a few interfaces that need to be implemented (presumably to just throw the unimplemented exception?). Do you mean JDBC 3.0 methods? What methods precisely? Are they implementable? Also, I have a patch for DatabaseMetaData to fix a bug in the metadata returned for BigDecimals. I have already tried to submit this patch 2 or 3 times (to peter@retep) but never heard back. It's only about 4 LOC but it makes introspecting the database much better. Is this the place to post a patch, and if I do, am I likely to get a response? You can send patches to the [EMAIL PROTECTED] list, preferably with a CC to this list. Yes, you will get a response. Usually, a patch is applied within a week (if the patch is good, of course). If a patch to the JDBC driver needs discussion first, that should be on this list. Regards, René Pijlman [EMAIL PROTECTED] ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [JDBC] Patch for jdbc2 ResultSet.java
Barry Lind wrote: Joseph, In looking at this patch it looks OK, except for the following change: ! if (index=-rows.size()) --- 725,737 ! if (index rows_size) I haven't looked at the entire method, but the change you made seems incorrect. Oops! Thanks for catching that. Cut and paste error. I hate those. If you want this patch to be applied it should be sent to the pgsql-patches mail list. I thought that jdbc stuff was preferred to be on the jdbc list. I guess not. new patch: *** ResultSet.java.orig Tue Sep 4 16:34:14 2001 --- ResultSet.java Wed Sep 5 15:35:59 2001 *** *** 134,140 { //release resources held (memory for tuples) if(rows!=null) { - rows.setSize(0); rows=null; } } --- 134,139 *** *** 709,716 public int findColumn(String columnName) throws SQLException { int i; ! ! for (i = 0 ; i fields.length; ++i) if (fields[i].getName().equalsIgnoreCase(columnName)) return (i+1); throw new PSQLException (postgresql.res.colname,columnName); --- 708,715 public int findColumn(String columnName) throws SQLException { int i; ! final int flen = fields.length; ! for (i = 0 ; i flen; ++i) if (fields[i].getName().equalsIgnoreCase(columnName)) return (i+1); throw new PSQLException (postgresql.res.colname,columnName); *** *** 726,736 if (index==0) throw new SQLException(Cannot move to index of 0); //if index0, count from the end of the result set, but check //to be sure that it is not beyond the first index if (index0) ! if (index=-rows.size()) ! internalIndex=rows.size()+index; else { beforeFirst(); return false; --- 725,737 if (index==0) throw new SQLException(Cannot move to index of 0); + final int rows_size = rows.size(); + //if index0, count from the end of the result set, but check //to be sure that it is not beyond the first index if (index0) ! if (index -rows_size) ! internalIndex = rows_size+index; else { beforeFirst(); return false; *** *** 739,745 //must be the case that index0, //find the correct place, assuming that //the index is not too large ! if (index=rows.size()) internalIndex = index-1; else { afterLast(); --- 740,746 //must be the case that index0, //find the correct place, assuming that //the index is not too large ! if (index = rows_size) internalIndex = index-1; else { afterLast(); *** *** 753,760 public void afterLast() throws SQLException { ! if (rows.size() 0) ! current_row = rows.size(); } public void beforeFirst() throws SQLException --- 754,762 public void afterLast() throws SQLException { ! final int rows_size = rows.size(); ! if (rows_size 0) ! current_row = rows_size; } public void beforeFirst() throws SQLException *** *** 967,973 public boolean isAfterLast() throws SQLException { ! return (current_row = rows.size() rows.size() 0); } public boolean isBeforeFirst() throws SQLException --- 969,976 public boolean isAfterLast() throws SQLException { ! final int rows_size = rows.size(); ! return (current_row = rows_size rows_size 0); } public boolean isBeforeFirst() throws SQLException *** *** 982,995 public boolean isLast() throws SQLException { ! return (current_row == rows.size() -1 rows.size() 0); } public boolean last() throws SQLException { ! if (rows.size() = 0) return false; ! current_row = rows.size() - 1; this_row = (byte [][])rows.elementAt(current_row); return true; } --- 985,1000 public boolean isLast() throws SQLException { ! final int rows_size = rows.size(); ! return (current_row == rows_size -1 rows_size 0); } public boolean last() throws SQLException { ! final int rows_size = rows.size(); ! if (rows_size = 0) return false; ! current_row = rows_size - 1; this_row = (byte [][])rows.elementAt(current_row); return true; } *** *** 1480,1483 } } } - --- 1485,1487 -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com ---(end of broadcast)--- TIP 4
[JDBC] Patch for jdbc2 ResultSet.java
Just some minor fixes to avoid duplicate function calls that were bugging me. If rows is garunteed not to change then we can store the size in a final class variable, but I wasn't sure I could assume that. *** ResultSet.java.orig Tue Sep 4 16:34:14 2001 --- ResultSet.java Tue Sep 4 16:45:20 2001 *** *** 134,140 { //release resources held (memory for tuples) if(rows!=null) { - rows.setSize(0); rows=null; } } --- 134,139 *** *** 709,716 public int findColumn(String columnName) throws SQLException { int i; ! ! for (i = 0 ; i fields.length; ++i) if (fields[i].getName().equalsIgnoreCase(columnName)) return (i+1); throw new PSQLException (postgresql.res.colname,columnName); --- 708,715 public int findColumn(String columnName) throws SQLException { int i; ! final int flen = fields.length; ! for (i = 0 ; i flen; ++i) if (fields[i].getName().equalsIgnoreCase(columnName)) return (i+1); throw new PSQLException (postgresql.res.colname,columnName); *** *** 726,736 if (index==0) throw new SQLException(Cannot move to index of 0); //if index0, count from the end of the result set, but check //to be sure that it is not beyond the first index if (index0) ! if (index=-rows.size()) ! internalIndex=rows.size()+index; else { beforeFirst(); return false; --- 725,737 if (index==0) throw new SQLException(Cannot move to index of 0); + final int rows_size = rows.size(); + //if index0, count from the end of the result set, but check //to be sure that it is not beyond the first index if (index0) ! if (index rows_size) ! internalIndex = rows_size+index; else { beforeFirst(); return false; *** *** 739,745 //must be the case that index0, //find the correct place, assuming that //the index is not too large ! if (index=rows.size()) internalIndex = index-1; else { afterLast(); --- 740,746 //must be the case that index0, //find the correct place, assuming that //the index is not too large ! if (index = rows_size) internalIndex = index-1; else { afterLast(); *** *** 753,760 public void afterLast() throws SQLException { ! if (rows.size() 0) ! current_row = rows.size(); } public void beforeFirst() throws SQLException --- 754,762 public void afterLast() throws SQLException { ! final int rows_size = rows.size(); ! if (rows_size 0) ! current_row = rows_size; } public void beforeFirst() throws SQLException *** *** 967,973 public boolean isAfterLast() throws SQLException { ! return (current_row = rows.size() rows.size() 0); } public boolean isBeforeFirst() throws SQLException --- 969,976 public boolean isAfterLast() throws SQLException { ! final int rows_size = rows.size(); ! return (current_row = rows_size rows_size 0); } public boolean isBeforeFirst() throws SQLException *** *** 982,995 public boolean isLast() throws SQLException { ! return (current_row == rows.size() -1 rows.size() 0); } public boolean last() throws SQLException { ! if (rows.size() = 0) return false; ! current_row = rows.size() - 1; this_row = (byte [][])rows.elementAt(current_row); return true; } --- 985,1000 public boolean isLast() throws SQLException { ! final int rows_size = rows.size(); ! return (current_row == rows_size -1 rows_size 0); } public boolean last() throws SQLException { ! final int rows_size = rows.size(); ! if (rows_size = 0) return false; ! current_row = rows_size - 1; this_row = (byte [][])rows.elementAt(current_row); return true; } *** *** 1480,1483 } } } - --- 1485,1487 -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
[JDBC] Re: JDBC Performance
This is typical. Until you do a vacuum the old versions of a row are still in the db, so an update has to do an index query on an index to get to the row that needs indexing, which returns a lot of pointers to old entries, that then have to be tranversed until the valid one in found. Then the update makes one more invalid row. [EMAIL PROTECTED] wrote: I am having some performance problems with postgresql and JDBC when it comes to updates. If I try and update a record it seems to be taking 1.7 seconds for 100 records or 14 seconds for 500 records. An insert is only taking between 3-5 ms/record. Performance on the updates continue to decrease until I vacuum analyze the database again. Is this normal? Mike -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send unregister YourEmailAddressHere to [EMAIL PROTECTED])
[JDBC] NullPointerException on next()
Using the jdbc 7.1.2 drivers: Exception in thread main java.lang.NullPointerException at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:116) that line is: if (++current_row = rows.size()) -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
[JDBC] Re: prepared statement performance
Perpared statements in postgres jdbc are converted on the java side and then shipped to the backed, so there will no performance increase. Sheer El-Showk wrote: Does anyone have some handy metrics of the performance advantage of prepared vs unprepared statements? I'm considering the case of an application which has to make multiple queries/inserts (30-100) per application transaction and which is currenlty generating the sql by building the strings on the fly then passing them to the JDBC. Can I expect significant (ie worth the recoding time) performance increases by converting the statements into prepared statements? -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
[JDBC] Re: Patch to remove connection hook and JDK 1.3 dependencies
Joseph Shraibman wrote: snip to do Bad Things. The java.policy file can have an entry to allow only code in org.postgres to add shutdown hooks (maybe we should put this in the documentation). grant codeBase file:///usr/local/pgsql/share/java/ { permission java.lang.RuntimePermission shutdownHooks; }; I think there is a way to grant permission based on what package a class is in (i.e. org.postgres) but I couln't find it. -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.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: Patch to remove connection hook and JDK 1.3 depen
Ned Wolpert wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 09-Jul-2001 Joseph Shraibman wrote: BTW having to add a line to your permission file for shutdown hooks is not a good reason to get rid of this feature. It most cases it would be Very true. However, having a shutdown hook that does nothing is a good reason get rid of it. That I conceed. I just tried to check out the latest cvs sources to see what was going on but my connection was refused. Is the cvs server temporarily down or did it move or what? -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
[JDBC] Vectors in 7.1 ResultSets
Why do the 7.1 ResultSets use Vectors where they used arrays in 7.0.x? Vectors are slower and create more garbage and have the overhead of synchronization for every method call. If there is some reason pre-sized arrays can't be used then ArrayLists should be used instead. -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.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] Re: Combo box
What are you talking about? Your interface has nothing to do with the jdbc drivers. Mihai Gheorghiu wrote: Is it possible to have more than one column in the drop-down of a combo box? I want the user to look at information from more than one database column when when selecting a value from a drop-down. -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.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] Re: [Fwd: JDBC Timestamp problem]
jdbc version don't follow postgres versions, so the jdbc drivers from the 7.1 codebase should work with a 7.0 server. Provided there aren't any bugs in those jdbc drivers, of course. Why are you using 7.0 when 7.0.3 is out? I think some of the timestamp problems were fixed in 7.0.3. Antonio Fiol wrote: Sorry, I sent the message to Peter only... Subject: Re: [JDBC] JDBC Timestamp problem Date: Thu, 22 Feb 2001 18:08:55 +0100 From: Antonio Fiol [EMAIL PROTECTED] Organization: w3ping To: Peter T Mount [EMAIL PROTECTED] References: [EMAIL PROTECTED] [EMAIL PROTECTED] Yes, there's been a lot of problems with timestamps, mainly where it was getting confused with timezone/millisecond variations. 99% of these have been fixed in the 7.1 driver. (I say 99% as there is bound to be a senario we've missed out ;-) ) Peter I downloaded the 7.0 three days ago Is there an RPM for the 7.1 stuff? Should I install all of the 7.1 packages, or should the JDBC driver be enough? If all of them are necessary, must I recreate my database, or can I upgrade cleanly, without touching to my data ? Thank you for answering that quickly Antonio Fiol W3ping -- Joseph Shraibman [EMAIL PROTECTED] Increase signal to noise ratio. http://www.targabot.com