1 package com.daffodilwoods.daffodildb.odbc; 2 3 import com.daffodilwoods.daffodildb.client.*; 4 import com.daffodilwoods.daffodildb.server.serversystem.*; 5 import com.daffodilwoods.daffodildb.server.sql99.dql.listenerevents.*; 6 import com.daffodilwoods.database.utility.*; 7 import in.co.daffodil.db.jdbc.*; 8 9 public class OdbcPreparedStatement extends OdbcResultSet{ 10 public OdbcPreparedStatement(){ 11 } 12 13 public OdbcPreparedStatement(String path) { 14 } 15 16 public Object execute(Object objPrep,Object [] parameters) throws Exception { 17 try { 18 _PreparedStatement preparedStatement = (_PreparedStatement)objPrep; 19 20 Object obj = preparedStatement.execute(parameters); 21 if (obj != null && 22 preparedStatement.getQueryType() == _PreparedStatement.queryexpression) { 23 RecordSet rs = new RecordSet(); 24 rs.setSelectIterator( (_SelectIterator) obj); 25 _RecordSetBufferIterator rsbi = rs.getIterator(); 26 obj = rsbi; 27 } 28 return obj; 29 } 30 catch (NullPointerException ex) { 31 throw ex; 32 } 33 } 34 35 public Object [] getOutParameters(Object result,int[] types)throws Exception { 36 CallResult callResult = (CallResult)result; 37 Object [] outParameters = (Object [])callResult.getOUTParameters(); 38 if(outParameters != null){ 39 for (int i = 0; i < outParameters.length; i++) { 40 if (outParameters[i] != null) { 41 outParameters[i] = Utilities.convertObject(outParameters[i], types[i]); 42 } 43 } 44 } 45 return outParameters; 46 } 47 48 public Object getResultFormCallResult(Object result) throws Exception { 49 CallResult callResult = (CallResult)result; 50 Object obj = callResult.getResult(); 51 if (obj != null && obj instanceof _SelectIterator) { 52 RecordSet rs = new RecordSet(); 53 rs.setSelectIterator( (_SelectIterator) obj); 54 _RecordSetBufferIterator rsbi = rs.getIterator(); 55 obj = rsbi; 56 } 57 return obj; 58 } 59 public int getRowCount(Object obj) throws Exception { 60 if (obj != null ){ 61 if (obj instanceof Number ) 62 return ( (Number ) obj).intValue(); 63 if(obj instanceof _RecordSetBufferIterator) 64 return (((_RecordSetBufferIterator)obj).getRowCount()); 65 } 66 return 0; 67 } 68 69 public int getQueryType(Object objPrep) throws Exception { 70 _PreparedStatement preparedStatement = (_PreparedStatement) objPrep; 71 return preparedStatement.getQueryType(); 72 } 73 74 public int getParameterCount(Object objPrep) throws Exception { 75 _PreparedStatement preparedStatement = (_PreparedStatement) objPrep; 76 return preparedStatement.getParameterCount(); 77 } 78 79 public int getParameterType(Object objPrep,int index) throws Exception { 80 _PreparedStatement preparedStatement = (_PreparedStatement) objPrep; 81 return preparedStatement.getParameterMetaData().getParameterDataType(index-1); 82 } 83 84 85 public Object getByteObject(byte val){ 86 return new Byte (val); 87 } 88 89 public Object getShortObject(short val){ 90 return new Short (val); 91 } 92 public Object getIntegerObject(int val){ 93 return new Integer (val); 94 } 95 public Object getLongObject(long val){ 96 return new Long (val); 97 } 98 99 public Object getDoubleObject(double val){ 100 return new Double (val); 101 } 102 103 public Object getFloatObject(float val){ 104 return new Float (val); 105 } 106 107 public Object getBooleanObject(boolean val){ 108 return Utilities.getBooleanValue(val); 109 } 110 111 public Object getDateObject(int year , int month, int day) { 112 year = year - 1900; 113 month = month - 1; 114 return new java.sql.Date (year,month,day); 115 } 116 117 public Object getTimeObject(int hours, int minutes , int seconds) { 118 return new java.sql.Time (hours,minutes,seconds); 119 } 120 121 public Object getTimeStampObject(int year , int month, int day , int hours, int minutes , int seconds, int nanos){ 122 year = year - 1900; 123 month = month - 1; 124 return new java.sql.Timestamp (year,month,day,hours,minutes,seconds,nanos); 125 } 126 127 public Object getColumnCharacteristicsFromPrep(Object obj) throws Exception { 128 return ( (_PreparedStatement) obj).getColumnCharacteristics(); 129 } 130 131 132 } 133 | Popular Tags |