Kbase P121264: SQL-92: Error "Value can not be converted to requested type" passing array parameters for INSERT in
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/31/2008 |
|
Status: Verified
SYMPTOM(s):
SQL-92: Error "Value can not be converted to requested type" passing array parameters for INSERT in a PreparedStatement.
[DataDirect][OpenEdge JDBC Driver]Value can not be converted to requested type.
The SQL-92 query involves an INSERT statement executed using a JDBC PreparedStatement Object.
Java code uses a prepareStatement to execute an SQL-92 INSERT 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.executeUpdateInternal(Unknown Source)
at com.ddtek.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
at TestPreparedStatementInsert.runTest1(TestPreparedStatementInsert.java:63)
at TestPreparedStatementInsert.runTests(TestPreparedStatementInsert.java:39)
at TestPreparedStatementInsert.main(TestPreparedStatementInsert.java:69)
Executing java code similar to the following:
import java.sql.*;
public class TestPreparedStatementInsert {
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 =
"INSERT INTO PUB.Salesrep (MonthQuota) VALUES(?)";
private Connection connection = null;
private Connection getConnection() {
if (connection == null) {
try {
// Load the driver
Class.forName(TestPreparedStatementInsert.DRIVER);
connection = DriverManager.getConnection(TestPreparedStatementInsert.DB_URL, TestPreparedStatementInsert.DB_USER, TestPreparedStatementInsert.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 {
runTest1();
} 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(TestPreparedStatementInsert.SQL1);
System.out.println("Query:" + TestPreparedStatementInsert.SQL1);
// SI_ACCT_NBR, SA_COMPANY_NBR, SI_CRED_RATING, SI_CRED_HIST_NBR, SI_CRED_HIST_PTS_NBR,
// SA_OPER_INIT, SI_PRD, SI_SEQ_NBR, SA_TRAN_DT, SA_TRAN_TM
String siCredHistNbr = "1;2;3;4;5;6;7;8;9;10;11;12";
int i = 0;
ps.setString(++i,siCredHistNbr);
int j = ps.executeUpdate();
ps.close();
}
public static void main(String[] args) {
TestPreparedStatementInsert o = new TestPreparedStatementInsert();
o.runTests();
}
}.
FACT(s) (Environment):
All Supported Operating Systems
OpenEdge 10.1A
OpenEdge 10.1B
CAUSE:
Bug# OE00135558
FIX:
Upgrade to OpenEdge 10.1B01 or later