SAP Knowledge Base Article - Preview

2898035 - jConnect driver not following precision correctly - SDK for SAP ASE

Symptom

  • jConnect should send correct Precision value in Parameter format when column datatype is 'Numeric/Decimal' - For example:

// create the table with decimal(38,1) datatype
String createTable = "if object_id('" + TABLE_NAME + "') is not null "
+ "begin drop table " + TABLE_NAME + " end "
+ "execute ('create table " + TABLE_NAME + " ( "
+ " Name varchar(30), C1 numeric(5,2), C2 decimal (5,2) " + ")')";

System.out.println(createTable);
Statement stmt = conn.createStatement();
stmt.execute(createTable);

String insertQuery = "insert into " + TABLE_NAME + " (Name, C1, C2)" + " values ( ? , ? , ?)";
System.out.println(insertQuery);

PreparedStatement prepStmt = conn.prepareStatement(insertQuery);
boolean isBatch = false;
if(args[4] != null && args[4].equalsIgnoreCase("batch"))
{
isBatch = true;
}

String values [] = new String [args.length - 5];
for (int j=0, i = 5; i < args.length; i++)
{
values[j++] = args[i];
}

if(isBatch)
{
for(int i=0; i<values.length; i++)
{
System.out.println("Insert using batch: " + values[i]);
prepStmt.setString(1, values[i]);
prepStmt.setBigDecimal(2, new BigDecimal(values[i]));
prepStmt.setBigDecimal(3, new BigDecimal(values[i]));

prepStmt.addBatch();
}

prepStmt.executeBatch();
SQLWarning warning = prepStmt.getWarnings();
while(warning != null)
{
System.out.print(" Warning: " + warning.getMessage());
warning = warning.getNextWarning();
}
}

  • Expected - precision as "5" and scale as "2"
  • Received - precision as "3" and scale as "2"


Read more...

Environment

  • SAP Sybase Software Developer Kit (SDK) 15.0
  • SAP Sybase Software Developer Kit (SDK) 15.5
  • SAP Sybase Software Developer Kit (SDK) 15.7
  • SAP Adaptive Server Enterprise (ASE) Software Developer Kit (SDK) 16.0
  • jConnect
    • JDBC 6.0.5
    • JDBE 7.0
    • JDBC 7.07
    • JDBC 16 (is version JDBC 7.07)

Product

SAP Adaptive Server Enterprise SDK 16.0 ; Sybase Software Developer Kit 15.7

Keywords

CR820175, CR ##820175, java, , KBA , BC-SYB-SDK , SDK , Bug Filed

About this page

This is a preview of a SAP Knowledge Base Article. Click more to access the full version on SAP ONE Support launchpad (Login required).

Search for additional results

Visit SAP Support Portal's SAP Notes and KBA Search.