Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changes merged from https://github.com/bagges/SQLDroid.git

  • Loading branch information...
commit 8a999c476d48ecd52911001626c06e0e2031c5ce 1 parent 19af694
@ergouser ergouser authored
View
18 compat/android/database/MatrixCursor.java
@@ -10,21 +10,27 @@
import java.util.List;
public class MatrixCursor implements Cursor {
-
+
/** The list of column names. */
protected String[] columnNames;
-
+
/** The ArrayList of values. This is populated by the "addRow" method and so is an list of object arrays. */
List<Object[]> rows;
/** The current position in the cursor. */
protected int currentPosition;
-
+
public MatrixCursor(String[] columnNames, int initialCapacity ) {
this.columnNames=columnNames;
rows = new ArrayList<Object[]>(initialCapacity);
currentPosition = -1;
- }
+ }
+
+ public MatrixCursor(String[] columnNames) {
+ this.columnNames=columnNames;
+ rows = new ArrayList<Object[]>();
+ currentPosition = -1;
+ }
public void addRow(Object[] column) {
rows.add(column);
@@ -132,7 +138,7 @@ public boolean isLast() {
@Override
public void requery() {
-
+
}
@Override
@@ -159,7 +165,7 @@ public String getColumnName(int i) {
public void moveToPosition(int oldPos) {
currentPosition = oldPos;
}
-
+
@Override
public int getType(int ci) {
// this should really intelligently determine the type and return a worthwhile value,
View
26 src/org/sqldroid/SQLDroidConnection.java
@@ -18,6 +18,7 @@
import java.sql.Struct;
import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.Executor;
import android.util.Log;
@@ -460,4 +461,29 @@ public void setClientInfo(String name, String value) throws SQLClientInfoExcepti
// TODO Auto-generated method stub
}
+
+ // methods added for JDK7 compilation
+
+ public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
+ // TODO Auto-generated method stub
+ }
+
+ public int getNetworkTimeout() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public void abort(Executor executor) throws SQLException {
+ // TODO Auto-generated method stub
+ }
+
+ public String getSchema() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setSchema(String schema) throws SQLException {
+ // TODO Auto-generated method stub
+ }
+ }
}
View
40 src/org/sqldroid/SQLDroidDatabaseMetaData.java
@@ -200,7 +200,7 @@ public ResultSet getColumns(String catalog, String schemaPattern,
column[2] = tableName;
column[3] = c.getString(1);
String type = c.getString(2);
- column[5] = type;
+ column[5] = type;
type = type.toUpperCase();
// types are (as far as I can tell, the pragma document is not specific):
if ( type.equals("TEXT" ) || type.startsWith("CHAR") ) {
@@ -569,12 +569,25 @@ public String getNumericFunctions() throws SQLException {
}
@Override
- public ResultSet getPrimaryKeys(String catalog, String schema, String table)
- throws SQLException {
- System.err.println(" ********************* not implemented @ "
- + DebugPrinter.getFileName() + " line "
- + DebugPrinter.getLineNumber());
- return null;
+ public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException {
+
+ final String[] columnNames = new String [] {"TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "KEY_SEQ", "PK_NAME"};
+ final Object[] columnValues = new Object[] {null, null, null, null, null, null};
+ SQLiteDatabase db = con.getDb();
+
+ Cursor c = db.rawQuery("pragma table_info('" + table + "')", new String[] {});
+ MatrixCursor mc = new MatrixCursor(columnNames);
+ while (c.moveToNext()) {
+ if(c.getInt(5) > 0) {
+ Object[] column = columnValues.clone();
+ column[2] = table;
+ column[3] = c.getString(1);
+ mc.addRow(column);
+ }
+ }
+ // The matrix cursor should be sorted by column name, but isn't
+ c.close();
+ return new SQLDroidResultSet(mc);
}
@Override
@@ -1626,5 +1639,18 @@ public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
// TODO Auto-generated method stub
return false;
}
+
+ // methods added for JDK7 compilation
+
+ public boolean generatedKeyAlwaysReturned() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
View
9 src/org/sqldroid/SQLDroidDriver.java
@@ -3,7 +3,9 @@
import java.sql.Connection;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
+import java.util.logging.Logger;
public class SQLDroidDriver implements java.sql.Driver {
@@ -85,4 +87,11 @@ public boolean jdbcCompliant() {
return false;
}
+ // methods added for JDK7 compilation
+
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ //TODO auto-generated code
+ return null;
+ }
+
}
View
75 src/org/sqldroid/SQLDroidPreparedStatement.java
@@ -452,7 +452,6 @@ public void setCursorName(String name) throws SQLException {
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -460,7 +459,6 @@ public void setEscapeProcessing(boolean enable) throws SQLException {
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -468,7 +466,6 @@ public void setFetchDirection(int direction) throws SQLException {
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -476,7 +473,6 @@ public void setFetchSize(int rows) throws SQLException {
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -484,7 +480,6 @@ public void setMaxFieldSize(int max) throws SQLException {
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -492,7 +487,6 @@ public void setMaxRows(int max) throws SQLException {
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -500,7 +494,6 @@ public void setQueryTimeout(int seconds) throws SQLException {
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -508,7 +501,6 @@ public void addBatch() throws SQLException {
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -538,7 +530,6 @@ public void setArray(int parameterIndex, Array theArray)
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -547,7 +538,6 @@ public void setAsciiStream(int parameterIndex, InputStream theInputStream,
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -556,7 +546,6 @@ public void setBigDecimal(int parameterIndex, BigDecimal theBigDecimal)
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
/**
* Set the parameter from the contents of a binary stream.
@@ -602,27 +591,20 @@ public void setBinaryStream(int parameterIndex, InputStream inputStream, int len
@Override
public void setBlob(int parameterIndex, Blob theBlob) throws SQLException {
-
ensureCap(parameterIndex);
setObj(parameterIndex, theBlob.getBytes(1, (int)theBlob.length()));
-
}
@Override
- public void setBoolean(int parameterIndex, boolean theBoolean)
- throws SQLException {
-
+ public void setBoolean(int parameterIndex, boolean theBoolean) throws SQLException {
ensureCap(parameterIndex);
setObj(parameterIndex, theBoolean);
-
}
@Override
public void setByte(int parameterIndex, byte theByte) throws SQLException {
-
ensureCap(parameterIndex);
setObj(parameterIndex, theByte);
-
}
@Override
@@ -638,7 +620,6 @@ public void setCharacterStream(int parameterIndex, Reader reader, int length)
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -657,70 +638,53 @@ public void setDate(int parameterIndex, Date theDate) throws SQLException {
}
@Override
- public void setDate(int parameterIndex, Date theDate, Calendar cal)
- throws SQLException {
+ public void setDate(int parameterIndex, Date theDate, Calendar cal) throws SQLException {
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
- public void setDouble(int parameterIndex, double theDouble)
- throws SQLException {
+ public void setDouble(int parameterIndex, double theDouble) throws SQLException {
ensureCap(parameterIndex);
setObj(parameterIndex, new Double(theDouble));
}
@Override
- public void setFloat(int parameterIndex, float theFloat)
- throws SQLException {
+ public void setFloat(int parameterIndex, float theFloat) throws SQLException {
ensureCap(parameterIndex);
setObj(parameterIndex, new Double(theFloat));
-
}
@Override
public void setInt(int parameterIndex, int theInt) throws SQLException {
ensureCap(parameterIndex);
setObj(parameterIndex, new Long(theInt));
-
-
-
}
@Override
public void setLong(int parameterIndex, long theLong) throws SQLException {
ensureCap(parameterIndex);
setObj(parameterIndex, new Long(theLong));
-
-
}
@Override
public void setNull(int parameterIndex, int sqlType) throws SQLException {
ensureCap(parameterIndex);
setObj(parameterIndex, null);
-
-
}
@Override
- public void setNull(int paramIndex, int sqlType, String typeName)
- throws SQLException {
+ public void setNull(int paramIndex, int sqlType, String typeName) throws SQLException {
ensureCap(paramIndex);
setObj(paramIndex, null);
-
}
@Override
- public void setObject(int parameterIndex, Object theObject)
- throws SQLException {
- System.err.println(" ********************* not implemented @ "
- + DebugPrinter.getFileName() + " line "
- + DebugPrinter.getLineNumber());
-
+ public void setObject(int parameterIndex, Object theObject) throws SQLException {
+ ensureCap(parameterIndex);
+ setObj(parameterIndex, theObject);
}
@Override
@@ -729,7 +693,6 @@ public void setObject(int parameterIndex, Object theObject,
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -738,7 +701,6 @@ public void setObject(int parameterIndex, Object theObject,
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -746,7 +708,6 @@ public void setRef(int parameterIndex, Ref theRef) throws SQLException {
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -754,16 +715,12 @@ public void setShort(int parameterIndex, short theShort)
throws SQLException {
ensureCap(parameterIndex);
setObj(parameterIndex, new Long(theShort));
-
-
}
@Override
public void setString(int parameterIndex, String theString) {
ensureCap(parameterIndex);
setObj(parameterIndex, theString);
-
-
}
@Override
@@ -771,7 +728,6 @@ public void setTime(int parameterIndex, Time theTime) throws SQLException {
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -780,7 +736,6 @@ public void setTime(int parameterIndex, Time theTime, Calendar cal)
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -796,7 +751,6 @@ public void setTimestamp(int parameterIndex, Timestamp theTimestamp, Calendar ca
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -804,7 +758,6 @@ public void setURL(int parameterIndex, URL theURL) throws SQLException {
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@Override
@@ -813,7 +766,6 @@ public void setUnicodeStream(int parameterIndex,
System.err.println(" ********************* not implemented @ "
+ DebugPrinter.getFileName() + " line "
+ DebugPrinter.getLineNumber());
-
}
@@ -990,5 +942,16 @@ public void setSQLXML(int parameterIndex, SQLXML xmlObject)
// TODO Auto-generated method stub
}
+
+ // methods added for JDK7 compilation
+
+ public boolean isCloseOnCompletion() throws SQLException {
+ //TODO auto generated code
+ return false;
+ }
+
+ public void closeOnCompletion() throws SQLException {
+ //TODO auto generated code
+ }
}
View
38 src/org/sqldroid/SQLDroidResultSet.java
@@ -425,14 +425,29 @@ public ResultSetMetaData getMetaData() throws SQLException {
@Override
public Object getObject(int colID) throws SQLException {
- //System.err.println(" ********************* not implemented @ " + DebugPrinter.getFileName() + " line " + DebugPrinter.getLineNumber());
- return getString(colID);
+ lastColumnRead = colID;
+ int newIndex = ci(colID);
+ switch(c.getType(newIndex)) {
+ case Cursor.FIELD_TYPE_BLOB:
+ //CONVERT TO BYTE[] OBJECT
+ return new SQLDroidBlob(c.getBlob(newIndex));
+ case Cursor.FIELD_TYPE_FLOAT:
+ return new Float(c.getFloat(newIndex));
+ case Cursor.FIELD_TYPE_INTEGER:
+ return new Integer(c.getInt(newIndex));
+ case Cursor.FIELD_TYPE_STRING:
+ return c.getString(newIndex);
+ case Cursor.FIELD_TYPE_NULL:
+ return null;
+ default:
+ return c.getString(newIndex);
+ }
}
@Override
public Object getObject(String columnName) throws SQLException {
- //System.err.println(" ********************* not implemented @ " + DebugPrinter.getFileName() + " line " + DebugPrinter.getLineNumber());
- return getString(columnName);
+ int index = c.getColumnIndex(columnName);
+ return getObject(index);
}
@Override
@@ -449,6 +464,21 @@ public Object getObject(String arg0, Map<String, Class<?>> arg1)
return null;
}
+
+ public <T> T getObject(int columnIndex, Class<T> clazz) throws SQLException {
+ // This method is entitled to throw if the conversion is not supported, so,
+ // since we don't support any conversions we'll throw.
+ // The only problem with this is that we're required to support certain conversion as specified in the docs.
+ throw new SQLException("Conversion not supported. No conversions are supported. This method will always throw.");
+ }
+
+ public <T> T getObject(String columnLabel, Class<T> clazz) throws SQLException {
+ // This method is entitled to throw if the conversion is not supported, so,
+ // since we don't support any conversions we'll throw.
+ // The only problem with this is that we're required to support certain conversion as specified in the docs.
+ throw new SQLException("Conversion not supported. No conversions are supported. This method will always throw.");
+ }
+
@Override
public Ref getRef(int colID) throws SQLException {
System.err.println(" ********************* not implemented @ " + DebugPrinter.getFileName() + " line " + DebugPrinter.getLineNumber());
View
10 src/org/sqldroid/SQLDroidStatement.java
@@ -387,5 +387,15 @@ public void setPoolable(boolean poolable) throws SQLException {
+ DebugPrinter.getLineNumber());
}
+
+ // methods added for JDK7 compilation
+ public boolean isCloseOnCompletion() throws SQLException {
+ //TODO auto generated code
+ return false;
+ }
+
+ public void closeOnCompletion() throws SQLException {
+ //TODO auto generated code
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.