Answer the question
In order to leave comments, you need to log in
How to create a new user and table in SQLite (eclipse -> java)?
I don't know how to create a user and a table in SQLite...
This code ran. The sqlite-jdbc driver version is 3.8.6.
package sqlite;
import java.sql.*;
public class sqlite {
public static void main(String[] args) throws Exception {
Class.forName("org.sqlite.JDBC");
Connection conn =
DriverManager.getConnection("jdbc:sqlite:test.db");
Statement stat = conn.createStatement();
stat.executeUpdate("drop table if exists people;");
stat.executeUpdate("create table people (name, occupation);");
PreparedStatement prep = conn.prepareStatement(
"insert into people values (?, ?);");
prep.setString(1, "Gandhi");
prep.setString(2, "politics");
prep.addBatch();
prep.setString(1, "Turing");
prep.setString(2, "computers");
prep.addBatch();
prep.setString(1, "Wittgenstein");
prep.setString(2, "smartypants");
prep.addBatch();
conn.setAutoCommit(false);
prep.executeBatch();
conn.setAutoCommit(true);
ResultSet rs = stat.executeQuery("select * from people;");
while (rs.next()) {
System.out.println("name = " + rs.getString("name"));
System.out.println("job = " + rs.getString("occupation"));
}
rs.close();
conn.close();
}
}
Answer the question
In order to leave comments, you need to log in
What user? Those. to add the user in , or to create the table "user"? In any case, in the subd users are stored in their own table, it is enough to have the rights to change it.
Google can probably suggest something on the topic:
https://www.google.com/#q=create+table+jdbc
https://www.google.com/#q=add+user+jdbc
https: //www.google.com/#q=sqlite+create+table
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question