get MySql Connection - Java java.sql

Java examples for java.sql:MySQL

Description

get MySql Connection

Demo Code


//package com.java2s;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getMySqlConnection());
    }//w ww  . j a  va 2 s .c  o m

    public static Connection getMySqlConnection() throws SQLException {
        return DriverManager.getConnection(
                "jdbc:mysql://localhost/twitter", "twitteruser",
                "twitteruserpw");
    }
}

Related Tutorials