Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- public class test {
- public static void main(String[] args) {
- Connection con = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", "username", "password");
- // Do shit
- } catch(Exception e) {
- e.printStackTrace();
- } finally {
- if(con != null) {
- try {
- con.close();
- } catch(Exception e) {
- e.printStackTrace();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement