主题:JSP怎样配置数据库连接啊
JSP+TOMCAT+MSSQL怎样配置数据库连接池啊
public static void main(String args [])
{
try{
InititalContext ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("mydb");
Connection con=ds.getConnection();
Statement stm=con.createStatement();
String sql="select * from user_tbl";
ResultSet rs=stm.executeQuery(sql);
while(rs.next())
{System.out.print(rs.getString(1));
}
}
catch(SQLException e)
{e.printStackTrace();
}
}
但是那个InititalContext can not find symbol
public static void main(String args [])
{
try{
InititalContext ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("mydb");
Connection con=ds.getConnection();
Statement stm=con.createStatement();
String sql="select * from user_tbl";
ResultSet rs=stm.executeQuery(sql);
while(rs.next())
{System.out.print(rs.getString(1));
}
}
catch(SQLException e)
{e.printStackTrace();
}
}
但是那个InititalContext can not find symbol