Thread: setArray()
Hi, I'd like to insert a large array of integers into the database (15000) However I can't seem to get PreparedStatement.setArray() to work. I saw a patch in the archives regarding this but I'm not in control of the java installation which I'm using. I'm currently converting my array into a string before inserting it and using setString()... However this is *very* slow! Any advice would be much appreciated, Conor
On Mon, 12 Jan 2004, Conor Beverland wrote: > Hi, > > I'd like to insert a large array of integers into the database (15000) > However I can't seem to get PreparedStatement.setArray() to work. > At the moment there is no way for user code to instantiate an Array object, so calling setArray will only work with an array you got from a ResultSet. > I saw a patch in the archives regarding this but I'm not in control of > the java installation which I'm using. > > I'm currently converting my array into a string before inserting it > and using setString()... However this is *very* slow! Behind the scenes the driver would do the exact same thing, so even if you could call setArray() it wouldn't help your performace problem. Kris Jurka
I have the same issue, but my Array is much smaller. As you see downthread, there is no practical way to use setArray(). As for speed: Are you using a StringBuffer allocated sufficiently large to begin with, not a String? (My last line is return new String(sbuffer); HTH. ----- Original Message ----- From: "Conor Beverland" <cb801@doc.ic.ac.uk> To: <pgsql-jdbc@postgresql.org> Sent: Monday, January 12, 2004 6:40 AM Subject: [JDBC] setArray() > Hi, > > I'd like to insert a large array of integers into the database (15000) > However I can't seem to get PreparedStatement.setArray() to work. > > I saw a patch in the archives regarding this but I'm not in control of > the java installation which I'm using. > > I'm currently converting my array into a string before inserting it > and using setString()... However this is *very* slow! > > Any advice would be much appreciated, > Conor > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match