# 引入POM相关依赖
```xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.gosuncn
jdbc
1.0
mysql
mysql-connector-java
5.1.6
org.apache.maven.plugins
maven-compiler-plugin
3.7.0
1.8
1.8
UTF-8
```
# 获取连接
```java
package com.gosuncn;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
import java.util.Properties;
public class ConnectionMain {
public static void main(String[] args) throws SQLException {
Driver driver = new com.mysql.jdbc.Driver();
String url = "jdbc:mysql://127.0.0.1:3306/test";
Properties info = new Properties();
info.setProperty("user", "root");
info.setProperty("password", "root");
Connection connect = driver.connect(url, info);
System.out.println(connect);
}
}
```