Re: [JDBC] Using char fields with 7.1.3 driver
I'm not a JDBC expert, but this is pretty much the way I'd expect it to work. If you a have fixed length field, then the field should return that many characters. The varchar implies it's variable length, so trailing spaces would then not be included. David ---(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)
> 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
Re: [JDBC] SQL CHAR type using setByte()
A quick review of the JDBC code shows that in fact everything that you pass into the driver is converted to a String first. Since Java char fields are 16 bit unicode characters, how does one go about using the SQL type CHAR(1), which by default is only one byte (there is no call setChar() in JDBC)? I see that the driver has a type TINYINT, but I have no idea what that maps to in Postgresql or in Java, though it sure sounds like a byte to me. David ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://www.postgresql.org/search.mpl
[JDBC] SQL CHAR type using setByte()
I have a Java byte field that I'm trying to store in the database. It has a value of (byte)'0' which is a binary 48. When I use preparedStatement.setByte() with that value, to store in a Postgresql CHAR field, it only stores a '4'. It's as if the binary 48 were being converted to a String and then the first byte from the string was stored in the database. I'm using 7.1.1beta4. Does this make any sense? Am I using the wrong SQL type or the wrong JDBC PreparedStatement set call? Thanks, David
Re: [JDBC] serialized objects and JDBC driver
> ByteArrayInputStream bis = new ByteArrayInputStream(data); > ObjectInputStream p = new ObjectInputStream(bis); > EncryptionInfo ei = (EncryptionInfo)p.readObject(); Are you using setBytes/getBytes in JDBC? That's worked for me when the SQL type is OID on 7.1beta4. David ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html