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[] argv) throws Exception {

        String driverName = "com.jnetdirect.jsql.JSQLDriver";
        Class.forName(driverName);

        String serverName = "127.0.0.1";
        String portNumber = "1433";
        String mydatabase = serverName + ":" + portNumber;
        String url = "jdbc:JSQLConnect://" + mydatabase;
        String username = "username";
        String password = "password";

        Connection connection = DriverManager.getConnection(url, username, password);

        Statement stmt = connection.createStatement();

        String sql = "CREATE TABLE mysql_all_table(" + "col_boolean       BOOL, " // boolean
                + "col_byte          TINYINT, " // byte
                + "col_short         SMALLINT, " // short
                + "col_int           INTEGER, " // int
                + "col_long          BIGINT, " // long
                + "col_float         FLOAT, " // float
                + "col_double        DOUBLE PRECISION, " // double
                + "col_bigdecimal    DECIMAL(13,0), " // BigDecimal
                + "col_string        VARCHAR(254), " // String
                + "col_date          DATE, " // Date
                + "col_time          TIME, " // Time
                + "col_timestamp     TIMESTAMP, " // Timestamp
                + "col_asciistream   TEXT, " // AsciiStream (< 2^16 bytes)
                + "col_binarystream  LONGBLOB, " // BinaryStream (< 2^32 bytes)
                + "col_blob          BLOB)"; // Blob (< 2^16 bytes)

        stmt.executeUpdate(sql);

    }
}