parent
dc01bad92d
commit
8e4fecf3cc
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_10" default="false" project-jdk-name="10" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
@ -1,49 +0,0 @@
|
||||
package gdms;
|
||||
import core.user.Student;
|
||||
import core.user.User;
|
||||
import dao.DBManagement;
|
||||
import org.apache.tomcat.jdbc.pool.DataSource;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class test {
|
||||
public test(){
|
||||
Connection con = null;
|
||||
try{
|
||||
con = DBManagement.getConnection();
|
||||
Statement stmt = con.createStatement(); //创建Statement对象
|
||||
System.out.print("成功连接到数据库!");
|
||||
String sql = "select * from test";
|
||||
ResultSet rs = stmt.executeQuery(sql);
|
||||
rs.next();
|
||||
System.out.println(rs.getString("name"));
|
||||
rs.close();
|
||||
stmt.close();
|
||||
con.close();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if(con!=null) {
|
||||
try {
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static void main(String argc[]) throws NamingException, SQLException {
|
||||
new test();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue