Permalink
Browse files

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

  • Loading branch information...
ergouser committed Aug 29, 2012
1 parent 19af694 commit 8a999c476d48ecd52911001626c06e0e2031c5ce
@@ -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,
@@ -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
+ }
+ }
}
@@ -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;
+ }
+
}
@@ -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;
+ }
+
}
Oops, something went wrong.

0 comments on commit 8a999c4

Please sign in to comment.