Commit 9d20efe8 by 钟明宏

Delete MysqlTest.java

删除mysql测试代码
parent daa2b629
package cn.yunmaozj.tools.excel.sql;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.sql.*;
/**
* @author zhongminghong
* @email zhongmh@yunmaozj.com
* @create 2020-04-19 20:25
*/
public class MysqlTest {
private String url = "jdbc:mysql://120.25.127.156:3306/mysql?useUnicode=yes&characterEncoding=UTF-8&useInformationSchema=true&useSSL=false&serverTimezone=UTC";
private String user = "root";
private String password = "hgL0oT%koZZw";
private String driver = "com.mysql.cj.jdbc.Driver";
private Connection connection;
@Test
public void demo() throws SQLException {
PreparedStatement statement = connection.prepareStatement("SELECT * FROM `COLUMNS` WHERE TABLE_SCHEMA = 'user'");
ResultSet resultSet = statement.executeQuery();
ResultSetMetaData metaData = resultSet.getMetaData();
for(int i=1;i<=metaData.getColumnCount();i++){
System.out.println(metaData.getColumnName(i));
}
while (resultSet.next()){
for(int i=1;i<=metaData.getColumnCount();i++){
System.out.println(metaData.getColumnName(i)+" Value -> "+resultSet.getObject(i));
}
}
}
@Before
public void init() throws SQLException, ClassNotFoundException {
Class.forName(driver);
connection = DriverManager.getConnection(url, user, password);
}
@After
public void close() throws SQLException {
if (!connection.isClosed()) {
connection.close();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment