Java Code Examples for com.almworks.sqlite4java.SQLiteStatement#columnDouble()

The following examples show how to use com.almworks.sqlite4java.SQLiteStatement#columnDouble() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DbUtils.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T> T extract(SQLiteStatement stmt, Class<T> type, int idx) throws Exception {
   if (type == String.class) {
      return (T) stmt.columnString(idx);
   } else if (type == int.class || type == Integer.class) {
      return (T) (Integer) stmt.columnInt(idx);
   } else if (type == long.class || type == Long.class) {
      return (T) (Long) stmt.columnLong(idx);
   } else if (type == double.class || type == Double.class) {
      return (T) (Double) stmt.columnDouble(idx);
   } else if (type == byte[].class) {
      return (T) stmt.columnBlob(idx);
   } else if (type == Object.class) {
      return (T) stmt.columnValue(idx);
   } else {
      throw new DbException("cannot get column type: " + type);
   }
}
 
Example 2
Source File: SQLite3StatementBindInvoker.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
@Nullable
public static Object bind(SQLiteStatement stmt, Class<?> type, int index) {
   try {
      if (type.equals(String.class)) {
         return stmt.columnString(index);
      } else if (type.equals(Integer.class) || type.equals(int.class) ) {
         return stmt.columnInt(index);
      } else if (type.equals(Long.class) || type.equals(long.class)) {
         return stmt.columnLong(index);
      } else if (type.equals(Byte.class) || type.equals(byte.class) ) {
         return (byte)stmt.columnInt(index);
      } else if ( type.equals(Boolean.class) || type.equals(boolean.class) ) {
         return stmt.columnInt(index) != 0;
      } else if (type.equals(Double.class) || type.equals(double.class)) {
         return stmt.columnDouble(index);
      } else if (type.equals(float.class) || type.equals(Float.class)) {
         return (float)stmt.columnDouble(index);
      } else if (type.equals(Serializable.class)) {
         return stmt.columnBlob(index);
      }
   } catch (SQLiteException e) {
      log.error("sql bind invoker could not invoke:" , e);
   }

   return null;
}
 
Example 3
Source File: TestDbService.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Override
public TestPojo extract(SQLiteConnection conn, SQLiteStatement stmt) throws Exception {
   TestPojo result = new TestPojo();
   result.key = stmt.columnString(0);
   result.value1 = stmt.columnLong(1);
   result.value2 = stmt.columnDouble(2);

   byte[] value3 = stmt.columnBlob(3);
   if (value3 == null) {
      value3 = new byte[0];
   }

   result.value3 = value3;
   return result;
}