mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
添加测试
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@285 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.alibaba.druid.sql;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class TestOnlineSQLTest3 extends TestCase {
|
||||
|
||||
private String url = "jdbc:mysql://10.249.192.221/test";
|
||||
private String user = "dragoon";
|
||||
private String password = "dragoon";
|
||||
|
||||
protected Connection conn;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
conn = DriverManager.getConnection(url, user, password);
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
if (conn != null) {
|
||||
conn.close();
|
||||
conn = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void test_0 () throws Exception {
|
||||
String sql = "SELECT * FROM m_sql_const";
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
ResultSet rs = stmt.executeQuery(sql);
|
||||
while (rs.next()) {
|
||||
long id = rs.getLong(1);
|
||||
String value = rs.getString(2);
|
||||
handle(id, value);
|
||||
}
|
||||
rs.close();
|
||||
|
||||
stmt.close();
|
||||
}
|
||||
|
||||
void handle(long id, String value) {
|
||||
String sql = value.toString();
|
||||
|
||||
|
||||
|
||||
System.out.println(sql);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user