[MonetDB-users] JDBC driver
I installed MonetDB_JDBC-1.2-Blunt-SR1.jar and I am getting the following problem when I try to load MonetDriver using class.forName(): java.lang.UnsupportedClassVersionError: nl/cwi/monetdb/jdbc/MonetDriver (Unsupported major.minor version 49.0). Does any of you know what the problem is? Cheers, Rodrigo
The driver is compiled with Java 1.5, but your runtime environment is Java 1.4 Either use a 1.5 runtime environment, or compile the driver using ant and your 1.4 environment. Rodrigo Schmidt wrote:
I installed MonetDB_JDBC-1.2-Blunt-SR1.jar and I am getting the following problem when I try to load MonetDriver using class.forName():
java.lang.UnsupportedClassVersionError: nl/cwi/monetdb/jdbc/MonetDriver (Unsupported major.minor version 49.0).
Does any of you know what the problem is?
Cheers, Rodrigo
------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________ MonetDB-users mailing list MonetDB-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/monetdb-users
I have binary data that I want to store at the MonetDB server and manage it through the JDBC interface. I just figured out that Monet's JDBC interface does not implement set/getBytes() or set/getBlob(). I tried to create a String object out of my vector of bytes through new String(vector) but the string it generates is crap and the system halts. Any ideas to overcome the problem? Moreover, while surfing the source code of Monet's JDBC driver I found something weird. I think line 67 of MonetClob.java should be return(buf.substring((int)(pos - 1), (int)(pos-1 + length))); instead of return(buf.substring((int)(pos - 1), (int)(pos + length))); Cheers, Rodrigo
I have binary data that I want to store at the MonetDB server and manage it through the JDBC interface. I just figured out that Monet's JDBC interface does not implement set/getBytes() or set/getBlob(). I tried to create a String object out of my vector of bytes through new String(vector) but the string it generates is crap and the system halts.
Sorry... The system halts when I try to write this string on the database as a String using JDBC. Cheers, Rodrigo
Rodrigo Schmidt wrote:
Sorry... The system halts when I try to write this string on the database as a String using JDBC.
How exactly are you writing the String to the database? Using an insert statement? using a PreparedStatement? Can you enable the debuglog (append "?debug=true" to the JDBC connection URL as query string) and send it to us for further examination?
Hello,
How exactly are you writing the String to the database? Using an insert statement? using a PreparedStatement?
I sent part of my code in my previous message. I hope it helps. I previously tried with a Clob object and the result was the same (execution stalled). Then I had a quick look on the implementation of MonetClob and realized the result would be the same as if I used PreparedStatement.setString.
Can you enable the debuglog (append "?debug=true" to the JDBC connection URL as query string) and send it to us for further examination?
Of course, although I think it would be easier to debug with the code I sent before. I just do not know where this debuglog is written. Tell me and I send it to you. Cheers, Rodrigo
Rodrigo Schmidt wrote:
Of course, although I think it would be easier to debug with the code I sent before. I just do not know where this debuglog is written. Tell me and I send it to you.
Usually this is true, but since I don't have your data, I cannot exactly replicate your problem. I think the debuglog is going to tell me quite fast who is doing what wrong and where I have to look for to fix this issue. De debug log is written to the current working directory of the Java Runtime Environment and is named like monet_221637215371.log
Rodrigo Schmidt wrote:
I have binary data that I want to store at the MonetDB server and manage it through the JDBC interface. I just figured out that Monet's JDBC interface does not implement set/getBytes() or set/getBlob(). I tried to
getBytes() works, getBlob() doesn't. All setXXX() don't work, as we don't support updateable ResultSets. When setting/requesting this mode, an SQLWarning or SQLException should be generated telling you so. If not, this is a bug.
create a String object out of my vector of bytes through new String(vector) but the string it generates is crap and the system halts.
A Vector of bytes, so you have something like: Vector b = new Vector(); for (int i = 0; i < 10; i++) b.add(new Byte((byte)i)); and you want to put that in a String? byte[] bytes = (byte[])(b.toArray(new byte[b.length()])); String bindata = new String(bytes, "UTF-8"); then feed bindata to the driver. On a PreparedStatement it *should* work.
Any ideas to overcome the problem?
Moreover, while surfing the source code of Monet's JDBC driver I found something weird. I think line 67 of MonetClob.java should be
return(buf.substring((int)(pos - 1), (int)(pos-1 + length)));
I think you're right. That's a bug, thanks!
Hello,
getBytes() works, getBlob() doesn't. All setXXX() don't work, as we don't support updateable ResultSets. When setting/requesting this mode, an SQLWarning or SQLException should be generated telling you so. If not, this is a bug.
I am not trying to use a ResultSet to update values. I am using a preparedStatement, and setBytes and setBlob are not implemented for it in Monet's driver (these calls throw SQLException).
A Vector of bytes, so you have something like: Vector b = new Vector(); for (int i = 0; i < 10; i++) b.add(new Byte((byte)i));
and you want to put that in a String?
byte[] bytes = (byte[])(b.toArray(new byte[b.length()])); String bindata = new String(bytes, "UTF-8");
then feed bindata to the driver. On a PreparedStatement it *should* work.
This is more or less what I do and, unless I made some silly mistake while implementing (it would not be the first time), it does not work. Here it is briefly what I do (with comments pointing out what I verified during debugging): // MAXSIZE = 300000 ByteArrayOutputStream buffer = new ByteArrayOutputStream(MAXSIZE); ObjectOutputStream bufferwrapper = new ObjectOutputStream(buffer); bufferwrapper.writeObject("name1"); // I do not want to write "name1" into the database. This is just // an example. Actually, what I want to write is a Serialized // object. "name1" is just a simple object very suitable for testing. PreparedStatement addpropvalue = connect.prepareStatement( "INSERT INTO name (VERSION,VALUE) VALUES (1,?);"); // name is a table previously created with the structure // (VERSION INTEGER NOT NULL PRIMARY KEY, VALUE VARCHAR(300000)) addpropvalue.setBytes(1,buffer.toByteArray()); byte[] bv = buffer.toByteArray(); // contents checked at this point - OK String v = new String(bv,"UTF-8"); // contents checked again - OK // first bytes are binary code (below 32), last bytes // represent "name1" in ASCII addpropvalue.setString(1,v); addpropvalue.executeUpdate(); // execution stalls at this point. ---- Cheers, Rodrigo
Rodrigo Schmidt wrote:
I am not trying to use a ResultSet to update values. I am using a preparedStatement, and setBytes and setBlob are not implemented for it in Monet's driver (these calls throw SQLException).
Consider setBytes() method of PreparedStatement implemented now. Index: nl/cwi/monetdb/jdbc/MonetPreparedStatement.java =================================================================== RCS file: /cvsroot/monetdb/sql/src/jdbc/nl/cwi/monetdb/jdbc/MonetPreparedStatement.java,v retrieving revision 1.28 diff -u -r1.28 MonetPreparedStatement.java --- nl/cwi/monetdb/jdbc/MonetPreparedStatement.java 28 Jun 2005 19:36:36 -00001.28 +++ nl/cwi/monetdb/jdbc/MonetPreparedStatement.java 12 Aug 2005 11:01:35 -0000 @@ -530,7 +530,12 @@ * @throws SQLException if a database access error occurs */ public void setBytes(int parameterIndex, byte[] x) throws SQLException { - throw new SQLException("Operation currently not supported!"); + try { + setString(parameterIndex, new String(x, "UTF-8")); + } catch (UnsupportedEncodingException e) { + // this should never happen + throw new AssertionError(e.toString()); + } } /** I think my MUA screws up the diff, so it's only here for you to see what I did.
addpropvalue.setString(1,v); addpropvalue.executeUpdate(); // execution stalls at this point.
I'd like to have the log for this point. It's obviously waiting for something, and it looks like either the client or server violates the protocol in an undeterminable way.
participants (2)
-
Fabian
-
Rodrigo Schmidt