mysql 不能连接错了!
<%@ page language="java" contentType="text/html; charset=gb2312"pageEncoding="gb2312"%>
<%@page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Insert title here</title>
</head>
<body>
<%Connection con;
Statement sql;
ResultSet rs;
try{
Class.forName("org.gjt.mm.mysql.Driver");
}
catch(ClassNotFoundException e1){
out.print("类找不到!");
}
try{
con=DriverManager.getConnection("jdbc:mysql:localhost:8080zwz","text","123");
sql=con.createStatement();
rs=sql.executeQuery("select *from star");
out.print("<table border>");
out.print("<tr><td colspan=4 align=certer>歌手有这么些</td></tr>");
out.print("<tr>");
out.print("<td width=40>"+"标号");
out.print("<td width=400>"+"姓名");
out.print("<td width=40>"+"地区");
out.print("<td width=100"+"性别");
out.print("</tr>");
while (rs.next())
{
out.print("<tr>");
out.print("<td>"+rs.getLong(1)+"</td>");
out.print("<td>"+rs.getString(2)+"</td>");
out.print("<td>"+rs.getString(3)+"</td>");
out.print("<td>"+rs.getString(4)+"</td>");
out.print("<td><a href='index.jsp?stat_id="+rs.getLong(1)+"'>我要买!</a></td>");
out.print("</tr>");
out.print("</table>");
con.close();
}
}
catch(SQLException e2)
{
out.print("sql有错!");
}
%>
</body>
</html>
运行后得到了只有“sql有错!”请各位高手指出错误!谢谢 !~!