|
@ -1,7 +1,31 @@ |
|
|
package com.jesuspinar; |
|
|
package com.jesuspinar; |
|
|
|
|
|
|
|
|
|
|
|
import java.sql.Connection; |
|
|
|
|
|
import java.sql.DriverManager; |
|
|
|
|
|
import java.sql.Statement; |
|
|
|
|
|
|
|
|
public class Main { |
|
|
public class Main { |
|
|
public static void main(String[] args) { |
|
|
public static void main(String[] args) { |
|
|
|
|
|
//Editar USER y PWD |
|
|
|
|
|
final String USER = "root"; |
|
|
|
|
|
final String PWD = ""; |
|
|
|
|
|
Connection con; |
|
|
|
|
|
Statement query; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
// Cargamos driver |
|
|
|
|
|
Class.forName("sun.jdbc.odbc.jdbcOdbcDriver"); |
|
|
|
|
|
// Establecemos conexion |
|
|
|
|
|
con = DriverManager.getConnection("jdbc:odbc:pruebaodbc", USER, PWD); |
|
|
|
|
|
query = con.createStatement(); |
|
|
|
|
|
|
|
|
|
|
|
String createQuery = "CREATE TABLE IF NOT EXISTS TEST (ID INTEGER() NOT NULL AUTOINCREMENT, NOMBRE VARCHAR(50) NOT NULL, APELLIDOS VARCHAR(50) NOT NULL) "; |
|
|
|
|
|
String insertQuery = "INSERT INTO TEST VALUES('Juanjo','Pedraza'), ('Manel','Ruiz'), ('Yago','Cabrera')"; |
|
|
|
|
|
|
|
|
|
|
|
query.execute(createQuery); |
|
|
|
|
|
query.execute(insertQuery); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |