Синтаксис:
Используется javascript
package learnJDBC;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import com.mysql.jdbc.ReplicationDriver;
public class learnJDBC {
public static void main(String[] args) throws Exception {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/user/", "root", "luxurylife");
}
catch (ClassNotFoundException e) {
System.out.println("ClassNotFoundException: " + e.getMessage());
}
catch (SQLException e) {
System.out.println("SQLEXception: " + e.getMessage());
}
finally {
try {
if (con != null) con.close();
}
catch (SQLException ignored) { }
}
}
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import com.mysql.jdbc.ReplicationDriver;
public class learnJDBC {
public static void main(String[] args) throws Exception {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/user/", "root", "luxurylife");
}
catch (ClassNotFoundException e) {
System.out.println("ClassNotFoundException: " + e.getMessage());
}
catch (SQLException e) {
System.out.println("SQLEXception: " + e.getMessage());
}
finally {
try {
if (con != null) con.close();
}
catch (SQLException ignored) { }
}
}
}