MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;

public class MainClass {

    public static void main(String[] args) throws Exception {
        Class.forName("COM.cloudscape.core.JDBCDriver").newInstance();

        Connection conn = DriverManager.getConnection("jdbc:cloudscape:GAMETRADER");

        conn.setAutoCommit(false);

        Statement s = conn.createStatement();
        s.executeUpdate("CREATE TABLE MANUALS(GAMEID INT, MANUAL LONG VARCHAR)");
        conn.commit();

        File file = new File("manuals.xml");
        InputStream is = new FileInputStream(file);

        PreparedStatement ps = conn.prepareStatement("INSERT INTO MANUALS VALUES(?,?)");

        ps.setInt(1, 1285757);

        ps.setAsciiStream(2, is, (int) file.length());

        ps.execute();
        conn.commit();
    }
}