Java- MySQL Connection (Create Table, Insert, Select)



Java- MySQL Connection (Create Table, Insert, Select)

Java- MySQL Connection (Create Table, Insert, Select)

This is a fast tutorial, intended for people who understand java, and the basics of SQL/MySQL who just want to see how to use my-sql-connector.
How to create a MySQL Connection in java, then create a table, insert, and select, video 1 of 4.
CODE:
import java.sql.Connection;
import java.sql.DriverManager;

public static Connection getConnection() throws Exception{
try{
String driver = “com.mysql.jdbc.Driver”;
String url = “jdbc:mysql://24.196.52.166:3306/testdb”;
String username = “username”;
String password = “password”;
Class.forName(driver);

Connection conn = DriverManager.getConnection(url,username,password);
System.out.println(“Connected”);
return conn;
} catch(Exception e){System.out.println(e);}

return null;
}

Download JDBC https://dev.mysql.com/downloads/connector/j/ –06/07/2107

Comments are closed.