Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package mysql_oop;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.Statement;
- /**
- *
- * @author ACER
- */
- public class Mysql_oop {
- static final String jdbc_drivernya = "com.mysql.jdbc.Driver";
- static final String db_url = "jdbc:mysql://mysql.idhostinger.com:3306/u375462326_aplab";
- static final String USER = "u375462326_rts";
- static final String PASS = "123456";
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args){
- // TODO code application logic here
- Connection conn = null;
- Statement stmt = null;
- try{
- Class.forName(jdbc_drivernya);
- conn = DriverManager.getConnection(db_url, USER, PASS);
- System.out.println("Deleting database...");
- stmt = conn.createStatement();
- conn = DriverManager.getConnection(db_url, USER, PASS);
- stmt = conn.createStatement();
- String sql = "CREATE TABLE Person"
- + "(id INTEGER not NULL, "
- + " firstName VARCHAR(50), "
- + " lastName VARCHAR(50), "
- + " age INTEGER, "
- + " PRIMARY KEY ( id ))";
- stmt.executeUpdate(sql);
- System.out.println("Created table in given database...");
- stmt.close();
- conn.close();
- }catch(Exception e){
- System.out.println(e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement