netbeans连接mysql数据库总是连接不上
try{Class.forName("org.gjt.mm.mysql.Driver");}catch(ClassNotFoundExceptione){System.o...
try
{
Class.forName("org.gjt.mm.mysql.Driver");
}
catch(ClassNotFoundException e)
{
System.out.println("驱动程序加载错误");
}
try
{
Connection con = DriverManager.getConnection("jdbc:mysql//127.0.0.1:3306;DatabaseName=stu","root","gao");
Statement sql = con.createStatement();
ResultSet rs =sql.executeQuery("Select * from students where english>=60");
out.println("<table border ='1' bgcolor ='cyan'");
out.println("<tr>");
out.println("<td width = '50'>"+"学号"+"</td>");
out.println("<td width = '50'>"+"姓名"+"</td>");
out.println("<td width = '100'>"+"数学成绩"+"</td>");
out.println("<td width = '100'>"+"英语成绩"+"</td>");
out.println("<td width = '100'>"+"物理成绩"+"</td>");
out.println("</tr>");
while(rs.next())
{
................
}
out.println("</table>");
}
catch(SQLException e)
{
out.println("查询错误");
} 展开
{
Class.forName("org.gjt.mm.mysql.Driver");
}
catch(ClassNotFoundException e)
{
System.out.println("驱动程序加载错误");
}
try
{
Connection con = DriverManager.getConnection("jdbc:mysql//127.0.0.1:3306;DatabaseName=stu","root","gao");
Statement sql = con.createStatement();
ResultSet rs =sql.executeQuery("Select * from students where english>=60");
out.println("<table border ='1' bgcolor ='cyan'");
out.println("<tr>");
out.println("<td width = '50'>"+"学号"+"</td>");
out.println("<td width = '50'>"+"姓名"+"</td>");
out.println("<td width = '100'>"+"数学成绩"+"</td>");
out.println("<td width = '100'>"+"英语成绩"+"</td>");
out.println("<td width = '100'>"+"物理成绩"+"</td>");
out.println("</tr>");
while(rs.next())
{
................
}
out.println("</table>");
}
catch(SQLException e)
{
out.println("查询错误");
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询