Well I haven't had the chance to compile/test it yet but it should do the trick. I have only made modifications so far to getColumns() to add support for IS_AUTOINCREMENT. Basically, the table_info pragma returns a column called pk which is used to determine whether that column is a primary key or not. And according to the SQLite documentation, any INTEGER PRIMARY KEY auto increments. This patch should help you implement primary key support in the rest of the driver as well.
Patch: http://pastebin.com/f18ed673f On May 28, 1:00 am, Joe Wilson <[EMAIL PROTECTED]> wrote: > --- maddog39 <[EMAIL PROTECTED]> wrote: > > Maybe someone can point in the right direction. > > The source code is here: > > http://www.zentus.com/sqlitejdbc/src/ > > specifically: > > http://www.zentus.com/sqlitejdbc/src/src/org/sqlite/MetaData.java > > public ResultSet getPrimaryKeys(String c, String s, String table) > throws SQLException { > String sql; > ResultSet rs; > Statement stat = conn.createStatement(); > > rs = stat.executeQuery("pragma table_info('"+escape(table)+"');"); > > sql = "select " > + "null as TABLE_CAT, " > + "null as TABLE_SCHEM, " > + "'" + escape(table) + "' as TABLE_NAME, " > + "cn as COLUMN_NAME, " > + "0 as KEY_SEQ, " > + "null as PK_NAME from ("; > > int i; > for (i=0; rs.next(); i++) { > String colName = rs.getString(2); > > if (!rs.getBoolean(6)) { i--; continue; } > if (i > 0) sql += " union all "; > > sql += "select '" + escape(colName) + "' as cn"; > } > sql += i == 0 ? "select null as cn) limit 0;" : ");"; > rs.close(); > > return stat.executeQuery(sql); > } > > and > > public ResultSet getTypeInfo() throws SQLException { > if (getTypeInfo == null) { > getTypeInfo = conn.prepareStatement( > "select " > + "tn as TYPE_NAME, " > + "dt as DATA_TYPE, " > + "0 as PRECISION, " > + "null as LITERAL_PREFIX, " > + "null as LITERAL_SUFFIX, " > + "null as CREATE_PARAMS, " > + typeNullable + " as NULLABLE, " > + "1 as CASE_SENSITIVE, " > + typeSearchable + " as SEARCHABLE, " > + "0 as UNSIGNED_ATTRIBUTE, " > + "0 as FIXED_PREC_SCALE, " > + "0 as AUTO_INCREMENT, " > > If you get the functionality working, send a patch to the list. --~--~---------~--~----~------------~-------~--~----~ Mailing List: http://groups.google.com/group/sqlitejdbc?hl=en To unsubscribe, send email to [EMAIL PROTECTED] -~----------~----~----~----~------~----~------~--~---
