Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class Main {
    public static void main(String[] args) throws Exception {
        Connection conn = getConnection();
        conn.setAutoCommit(false);
        Statement st = conn.createStatement();

        st.executeUpdate("create table survey (id int,myURL CHAR);");

        String str = conn.nativeSQL("insert into survey(id) values(02)");

        System.out.println(str);

        conn.commit();
        st.close();
        conn.close();
    }

    private static Connection getConnection() throws Exception {
        Class.forName("org.hsqldb.jdbcDriver");
        String url = "jdbc:hsqldb:mem:data/tutorial";

        return DriverManager.getConnection(url, "sa", "");
    }
}