D
D
Dmitry Belousov2016-05-02 17:20:17
Database
Dmitry Belousov, 2016-05-02 17:20:17

How to properly connect to a database (SQLite) and how to pass values ​​to it?

// --------ПОДКЛЮЧЕНИЕ К БАЗЕ ДАННЫХ--------
    public static void Conn() throws ClassNotFoundException, SQLException
    {
        conn = null;
        Class.forName("org.sqlite.JDBC");
        conn = DriverManager.getConnection("jdbc:sqlite:TEST1.s3db");

        System.out.println("База Подключена!");
    }

public static void WriteDB(String login, String name, String password) throws ClassNotFoundException, SQLException
    {
        statmt = conn.createStatement();
        statmt.execute("INSERT INTO 'users' ('login', 'name', 'password') VALUES (login, name, password); ");INT);");
    }

Have I connected to the database correctly and how can I pass login, name, password parameters in the writeDB() method to the database?
PS The table was created in the SQLite program

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
VZVZ, 2016-05-02
@dreven

Well does it work? So, right.
Where to transfer and why? Do you want to enter these values ​​in the table? INSERT query for help.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question