1 package org.apache.ojb.broker.platforms; 2 3 17 18 import java.io.ByteArrayInputStream ; 19 import java.math.BigDecimal ; 20 import java.sql.PreparedStatement ; 21 import java.sql.ResultSet ; 22 import java.sql.SQLException ; 23 import java.sql.Statement ; 24 import java.sql.Types ; 25 26 import org.apache.ojb.broker.query.LikeCriteria; 27 import org.apache.ojb.broker.util.logging.LoggerFactory; 28 29 33 public class PlatformMsAccessImpl extends PlatformDefaultImpl 34 { 35 38 public void setObjectForStatement(PreparedStatement ps, int index, Object value, int sqlType) 39 throws SQLException 40 { 41 if (sqlType == Types.DECIMAL) 42 { 43 ps.setBigDecimal(index, (BigDecimal ) value); 44 } 45 else if (sqlType == Types.FLOAT) 46 { 47 if (value instanceof Double ) 51 { 52 ps.setDouble(index, ((Double ) value).doubleValue()); 53 } 54 else 55 { 56 super.setObjectForStatement(ps, index, value, sqlType); 57 } 58 } 59 else if (sqlType == Types.LONGVARCHAR) 61 { 62 if (value instanceof String ) 63 { 64 String s = (String ) value; 65 byte[] bytes = s.getBytes(); 68 ByteArrayInputStream bais = new ByteArrayInputStream (bytes); 69 ps.setAsciiStream(index, bais, bytes.length); 70 } 71 else 72 { 73 super.setObjectForStatement(ps, index, value, sqlType); 74 } 75 } 76 else if (value instanceof Long ) 83 { 84 ps.setInt(index,((Long )value).intValue()); 85 } 86 else 87 { 88 super.setObjectForStatement(ps, index, value, sqlType); 89 } 90 } 91 92 95 public void beforeStatementClose(Statement stmt, ResultSet rs) throws PlatformException 96 { 97 if (rs != null) 98 { 99 try 100 { 101 rs.close(); 102 } 103 catch (SQLException e) 104 { 105 LoggerFactory.getDefaultLogger().warn( 106 "Resultset closing failed (can be ignored for MsAccess)"); 107 } 108 } 109 } 110 111 114 protected String getConcatenationCharacter() 115 { 116 return "&"; 117 } 118 119 122 public String getEscapeClause(LikeCriteria aCriteria) 123 { 124 return ""; 126 } 127 } 128 | Popular Tags |