Kbase P119070: SQL-92: Passing Array params generate "Value can not be converted" error
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  31/10/2008 |
|
Status: Verified
SYMPTOM(s):
SQL-92: Error "Value can not be converted to requested type" passing array parameters for UPDATE in a PreparedStatement.
[DataDirect][OpenEdge JDBC Driver]Value can not be converted to requested type.
The SQL-92 query involves an UPDATE statement executed using a JDBC PreparedStatement Object.
Java code uses a prepareStatement to execute an SQL-92 UPDATE statement.
The following exception is generated:
java.sql.SQLException: [DataDirect][OpenEdge JDBC Driver]Value can not be converted to requested type.
at com.ddtek.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.ddtek.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.ddtek.jdbc.base.BaseData.getInteger(Unknown Source)
at com.ddtek.jdbc.openedge.client.OpenEdgeClientRequest.packParamData(Unknown Source)
at com.ddtek.jdbc.openedge.client.OpenEdgeClientRequest.executePrepared(Unknown Source)
at com.ddtek.jdbc.openedge.OpenEdgeImplStatement.execute(Unknown Source)
at com.ddtek.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at com.ddtek.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
at com.ddtek.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source)
at ArrayParameter.runTest1(ArrayParameter.java:72)
at ArrayParameter.runTests(ArrayParameter.java:44)
at ArrayParameter.main(ArrayParameter.java:79)
Executing java code similar to the following:
import java.sql.*;
public class ArrayParameter {
private static final String DRIVER = "com.ddtek.jdbc.openedge.OpenEdgeDriver";
private static final String DB_URL = "jdbc:datadirect:openedge://localhost:23456;databaseName=sports2000";
private static final String DB_USER = "yshanshi";
private static final String DB_PASS = "progress";
private static final String SQL1 =
"UPDATE " +
"PUB.SalesRep " +
"SET MonthQuota = ? " +
"WHERE Region = ? " +
"AND RepName = ? " +
"AND SalesRep = ? ";
private Connection connection = null;
private Connection getConnection() {
if (connection == null) {
try {
// Load the driver
Class.forName(ArrayParameter.DRIVER);
connection = DriverManager.getConnection(ArrayParameter.DB_URL, ArrayParameter.DB_USER, ArrayParameter.DB_PASS);
DatabaseMetaData meta = connection.getMetaData ();
// Gets driver info:
System.out.println("\n=============\nDatabase Product Name is ... " + meta.getDatabaseProductName());
System.out.println("\nDatabase Product Version is " + meta.getDatabaseProductVersion());
System.out.println("\n=============\nJDBC Driver Name is ........ " + meta.getDriverName());
System.out.println("\nJDBC Driver Version is ..... " + meta.getDriverVersion());
System.out.println("\nJDBC Driver Major Version is " + meta.getDriverMajorVersion());
System.out.println("\nJDBC Driver Minor Version is " + meta.getDriverMinorVersion());
System.out.println("\n=============");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}
return connection;
}
public void runTests() {
try {
ru.nTest1();
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (connection != null)
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
public void runTest1() throws SQLException {
final String TEST_NAME = "PreparedStatement with an extent field";
Connection myConnection = getConnection();
PreparedStatement ps = myConnection.prepareStatement(ArrayParameter.SQL1);
System.out.println("Query:" + ArrayParameter.SQL1);
String siCredHistNbr = "1000;2000;3000;4000;5000;6000;7000;8000;9000;10000;11000;12000";
String srRegion = "Central";
String srRepName = "Pitt , Dirk K.";
String srSalesRep = "DKP";
int i = 0;
ps.setString(++i,siCredHistNbr);
ps.setString(++i,srRegion);
ps.setString(++i,srRepName);
ps.setString(++i,srSalesRep);
ResultSet rs = ps.executeQuery();
rs.close();
ps.close();
}
public static void main(String[] args) {
ArrayParameter o = new ArrayParameter();
o.runTests();
}
}.
FACT(s) (Environment):
All Supported Operating Systems
OpenEdge 10.1A
CAUSE:
Bug# OE00132860
FIX:
Upgrade to OpenEdge 10.1A02 or higher.