def setJDBCObject(self, stmt, index, obj, datatype=None): "Convert Django-models types into Java ones" if datatype is None: FilterDataHandler.setJDBCObject(self, stmt, index, obj) return if datatype == Types.TIMESTAMP and isinstance(obj, basestring): # Convert string into java.sql.Timestamp # The string is generated by Django using datetime.__str__ , # so the format is year-month-day hour:minute:second.microsecond d, t = obj.split(' ') hour, minute, second, microsecond = self._hour_minute_second_micro( t) year, month, day = self._year_month_day(d) # FIXME: This ignores microseconds obj = Database.Timestamp(year, month, day, hour, minute, second) # Database is an alias for zxJDBC elif datatype == Types.TIME and isinstance(obj, basestring): # Convert string into java.sql.Time hour, minute, second, microsecond = self._hour_minute_second_micro( obj) # FIXME: This ignores microseconds obj = Database.Time(int(hour), int(minute), int(second)) elif datatype == Types.DATE and isinstance(obj, basestring): year, month, day = self._year_month_day(obj) obj = Database.Date(year, month, day) FilterDataHandler.setJDBCObject(self, stmt, index, obj, datatype)
def setJDBCObject(self, statement, index, object, dbtype=None): if dbtype is None: if (isinstance(object, int_types)): statement.setObject(index, str(object), java_Types.BIGINT) elif (isinstance(object, _python_Decimal)): statement.setObject(index, str(object), java_Types.DECIMAL) else: statement.setObject(index, object) else: FilterDataHandler.setJDBCObject(self, statement, index, object, dbtype)
def setJDBCObject(self, statement, index, object, dbtype=None): if type(object) is ReturningParam: statement.registerReturnParameter(index, object.type) elif dbtype is None: if (isinstance(object, int)): statement.setObject(index, str(object), java_Types.BIGINT) elif (isinstance(object, _python_Decimal)): statement.setObject(index, str(object), java_Types.DECIMAL) else: statement.setObject(index, object) else: FilterDataHandler.setJDBCObject(self, statement, index, object, dbtype)
def setJDBCObject(self, statement, index, object, dbtype=None): if dbtype is None: if (isinstance(object, int)): statement.setObject(index, str(object), java_Types.INTEGER) elif (isinstance(object, long)): statement.setObject(index, str(object), java_Types.BIGINT) elif (isinstance(object, _python_Decimal)): statement.setObject(index, str(object), java_Types.DECIMAL) else: statement.setObject(index, object) else: FilterDataHandler.setJDBCObject(self, statement, index, object, dbtype)
def getPyObject(self, set, col, datatype): "Convert Java types into Python ones" if datatype in (Types.VARCHAR, Types.CHAR): return Py.newUnicode(set.getString(col)) elif datatype == Types.TIMESTAMP: # Convert java.sql.TimeStamp into datetime cal = GregorianCalendar() cal.time = set.getTimestamp(col) return datetime.datetime(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), cal.get(Calendar.MILLISECOND) * 1000) elif datatype == Types.TIME: # Convert java.sql.Time into time cal = GregorianCalendar() cal.time = set.getTime(col) return datetime.time(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), cal.get(Calendar.MILLISECOND) * 1000) elif datatype == Types.DATE: # Convert java.sql.Date into datetime cal = GregorianCalendar() cal.time = set.getDate(col) return datetime.date(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH)) else: return FilterDataHandler.getPyObject(self, set, col, datatype)
def setJDBCObject(self, stmt, index, obj, datatype=None) : "Convert Django-models types into Java ones" if datatype is None: FilterDataHandler.setJDBCObject(self, stmt, index, obj) return if datatype == Types.TIMESTAMP and isinstance(obj, basestring): # Convert string into java.sql.Timestamp # The string is generated by Django using datetime.__str__ , # so the format is year-month-day hour:minute:second.microsecond d, t = obj.split(' ') hour, minute, second, microsecond = self._hour_minute_second_micro(t) year, month, day = self._year_month_day(d) # FIXME: This ignores microseconds obj = Database.Timestamp(year, month, day, hour, minute, second) # Database is an alias for zxJDBC elif datatype == Types.TIME and isinstance(obj, basestring): # Convert string into java.sql.Time hour, minute, second, microsecond = self._hour_minute_second_micro(obj) # FIXME: This ignores microseconds obj = Database.Time(int(hour), int(minute), int(second)) elif datatype == Types.DATE and isinstance(obj, basestring): year, month, day = self._year_month_day(obj) obj = Database.Date(year, month, day) FilterDataHandler.setJDBCObject(self, stmt, index, obj, datatype)