<%@ page import="java.sql.*"%>
<%
try{
  Class.forName("org.gjt.mm.mysql.Driver").newInstance();
  String url1 ="jdbc:mysql://localhost/yourdb;user=用户名;password=密码";
  Connection conn= DriverManager.getConnection(url1);
}
catch(Exception e)
{
  out.print("联接不成功!");
}
%>

解决方案 »

  1.   

    http://www.csdn.net/expert/topic/670/670716.xml?temp=.531399
      

  2.   

    出现如下错误:
    500 Internal Server Error
    Error parsing JSP page /test.jspSyntax error in source/test.jsp.java:30: ';' expected. (JSP page line 6)
    String url ="jdbc:mysql://localhost/mydb?user=root&password=&useUnicode=true&characterEncoding=8859_1" 
                                                                                                          ^
    /test.jsp.java:52: 'try' without 'catch' or 'finally'. (JSP page line 16)
    if(__coreOut == out) __coreOut.write(__staticContent, 66, 5);
    ^
    /test.jsp.java:70: Type expected.
    catch(Exception __jspE2)
    ^
    3 errors
      

  3.   

    有语法错误:
    String url ="jdbc:mysql://localhost/mydb?user=root&password=&useUnicode=true&characterEncoding=8859_1"; 少了;号你的“{”或“}”匹配有问题。你仔细查查。
    要么帖出代码。
      

  4.   

    谢谢,各位的帮助!
    由于最近在忙其他方面的事,再加上本来好好的jsp服务器也出现问题,
    只好把此事暂时搁浅,过一天后再来请教各位,再次感谢!