我找不到用JAVA计算数据库中的表的数量和要滚动的系统的方法。计算数据库中表的数量sqlite
我有一个矩阵M的大小100000列x 100行,我不得不分裂复制多个表上的数据库的各种原因,我在那里解释。 现在我必须读取数据库以重新加载矩阵M2,其中M2 = M,M的全部内容,但不知道该怎么办,因为我找不到计算组成数据库的表的数量的方法包含M. 我发现这个话题:
Count the number of tables in the sqlite database
,但我无法找到 “光标” 和 “getReadableDatabase。” 我在哪里可以下载适用于java的最新版SQLite? 我使用以下版本:
“的sqlite-JDBC-3.7.15-快照2.jar”
如果我写:
int numero_tabelle = 0;
try {
Class.forName("org.sqlite.JDBC").getInterfaces();
String nome = "jdbc:sqlite:" + nome_database;
Connection conn = DriverManager.getConnection(nome);
Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery("SELECT COUNT(*) FROM sqlite_master WHERE type = 'table'");
//ResultSet rs = stat.executeQuery("SELECT * FROM sqlite_master WHERE type = 'table'");
numero_tabelle = rs.getInt("sqlite_master");
conn.close();
rs.close();
} catch (ClassNotFoundException a) {
System.out.println("Manca la libreria SQLITE.");
} catch (SQLException b) {
System.out.println(nome_database + " inesistente.");
System.out.println("E' anche possibile "
+ "che le risorse hardware siano insufficienti.");
}
System.out.println("Number of tables: " + numero_tabelle);
我得到:
SuperM.sqlite inesistente.
E' anche possibile che le risorse hardware siano insufficienti.
Number of tables: 0
:(
'Cursor'和'getReadableDatabase'是Android API。你知道如何用JDBC执行查询吗? – 2013-04-06 19:18:27
是的我知道这样的代码: rs = stat.executeQuery(“SELECT * FROM”+ nome_tabella); 但它提供了记录的数量,而不是表格... :( )除了sqlite-jdbc-3.7.15-SNAPSHOT-2.jar之外,我必须导入一些.jar文件才能使用Cursor和getReadableDatabase? – 2013-04-06 19:28:45
但我必须下载这个.jar文件?!?!? http://developer.android.com/sdk/index.html – 2013-04-06 21:59:00