OPENJPA-745 raise string right truncation error for Sybase

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@706493 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Fay Wang 2008-10-21 02:03:26 +00:00
parent e2388e9b3c
commit 1e4aa60859
3 changed files with 20 additions and 0 deletions

View File

@ -920,6 +920,7 @@ public class JDBCStoreManager
_conn = connectInternal();
if (ref)
_conn.ref();
_dict.initializeSettings(_conn);
} catch (SQLException se) {
throw SQLExceptions.getStore(se, _dict);
} finally {

View File

@ -200,6 +200,7 @@ public class DBDictionary
public String selectWords = null;
public String fixedSizeTypeNames = null;
public String schemaCase = SCHEMA_CASE_UPPER;
public boolean setStringRightTruncationOn = true;
// sql
public String validationSQL = null;
@ -4561,4 +4562,8 @@ public class DBDictionary
length));
return name;
}
public void initializeSettings(Connection conn)
throws SQLException {
}
}

View File

@ -269,6 +269,20 @@ public class SybaseDictionary
return new SybaseConnection(super.decorate(conn));
}
public void initializeSettings(Connection conn)
throws SQLException {
// In order for Sybase to raise the truncation exception when the
// string length is greater than the column length for Char, VarChar,
// Binary, VarBinary, the "set string_rtruncation on" must be executed.
// This setting is effective for the duration of current connection.
if (setStringRightTruncationOn) {
String str = "set string_rtruncation on";
PreparedStatement stmnt = prepareStatement(conn, str);
stmnt.execute();
stmnt.close();
}
}
/**
* Connection wrapper to cache the {@link Connection#getCatalog} result,
* which takes a very long time with the Sybase Connection (and