I am using the Java Mysql connector and I have a problem with extracting results:
This is the query and prepared statement that needed to be executed:
String statement1 = " select sentence from sentences ; ";
PreparedStatement preparedstatement = conn.prepareStatement(statement1);
ResultSet res = preparedstatement.executeQuery();
Now I try to get the results in an array, so I use:
Array temp = res.getArray("sentence"); //(1)
String[] temp2 = (String[])temp.getArray(); //(2)
(1) returns a mysql.array which contains a locator, which is a logical pointer to the SQL ARRAY on the server, and (2) should do a typecast of temp and return a String[], however I am getting this error
java.sql.SQLFeatureNotSupportedException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:374)
at com.mysql.jdbc.SQLError.notImplemented(SQLError.java:1342)
at com.mysql.jdbc.ResultSetImpl.getArray(ResultSetImpl.java:1226)
at com.mysql.jdbc.ResultSetImpl.getArray(ResultSetImpl.java:1243)
at wikiparse.Wikiparse3.running(Wikiparse3.java:62) // this where I wrote (1) in my java file
at wikiparse.ActivateWikiparse3.main(ActivateWikiparse3.java:27)
Any ideas?
preparedstatement.executeQuery(), the data is already on your side, rather than server side.sentencesdeclaration?In the following statement, the ResultSet method getArray returns the value stored in the column ZIPS of the current row as the java.sql.Array object z: Array z = rs.getArray("ZIPS"); The variable z contains a locator, which is a logical pointer to the SQL ARRAY on the server; it does not contain the elements of the ARRAY itself. Being a logical pointer, z can be used to manipulate the array on the server.postgresrather thanmysql?