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();
    }
}
