1 22 23 package org.xquark.mapper.dbms.sybase; 24 25 import java.sql.*; 26 27 import org.xquark.jdbc.typing.DBMSInfo; 28 import org.xquark.jdbc.typing.DbType; 29 import org.xquark.jdbc.typing.JavaTypeInfo; 30 import org.xquark.mapper.RepositoryException; 31 import org.xquark.mapper.dbms.JDBC2Connection; 32 33 37 public class ASE119Connection extends JDBC2Connection 38 { 39 private static final String RCSRevision = "$Revision: 1.2 $"; 40 private static final String RCSName = "$Name: $"; 41 42 43 44 public ASE119Connection(Connection connection, short dbms, DBMSInfo dbmsInfo) 45 throws SQLException 46 { 47 super(connection, dbms, dbmsInfo); 48 } 49 50 protected void setSchemaName() throws SQLException 51 { 52 Statement stmt = null; 53 try { 54 stmt = connection.createStatement(); 55 ResultSet rs = stmt.executeQuery("select USER_NAME()"); 56 if (rs.next()) 57 schemaName = rs.getString(1); 58 rs.close(); 59 } 60 finally { 61 stmt.close(); 62 } 63 } 64 public void setObject(PreparedStatement pStmt, int index, Object o, int javaType, DbType sqlType) throws SQLException 68 { 69 if ((javaType == JavaTypeInfo.JAVA_BIG_DECIMAL) 70 && (sqlType.getJDBCType() == Types.DECIMAL) 71 && (sqlType.getScale() <= 2)) 72 pStmt.setFloat(index, ((Number )o).floatValue()); 73 else 74 pStmt.setObject(index, o); 75 } 76 77 public void dropTemporaryTable(String tableName) throws SQLException 81 { 82 super.dropTemporaryTable("#" + tableName); 83 } 84 85 public String getDeleteUserTableRowsStatement(String tableName, String documentRowsSelectionClause) 86 throws SQLException, RepositoryException 87 { 88 StringBuffer deletionStmt = new StringBuffer (); 89 deletionStmt.append("DELETE "); 90 deletionStmt.append(tableName); 91 deletionStmt.append(' '); 92 deletionStmt.append(documentRowsSelectionClause); 93 94 return deletionStmt.toString(); 95 } 96 97 99 public boolean useStringDelimitor() 100 { 101 return true; 102 } 103 104 109 } 110 | Popular Tags |