JSP中调用java中的方法-最后一句会出错 请指教
package com.yuu.www;
import
java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import
javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
import java.util.*;
public class SecretImport extends HttpServlet {
public void doGet(HttpServletRequest req,HttpServletResponse resp)
throws
ServletException,
IOException{
process(req,resp);
}
protected void doPost(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,IOException {
process(req,resp);
}
private void process(HttpServletRequest req,HttpServletResponse resp)
throws IOException{
try{
String username = req.getParameter("username");
String password=req.getParameter("password");
System.out.print(username);
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
out.println("<html><head><title>Login</title></head>");
out.println("<body>username:"+username+"<br>");
out.println("password:"+password+"</body></html>");
out.flush();}
catch(Exception e){e.printStackTrace();}
}
}
class DbConnect {
private Connection dbconn;
private Statement dbstate;
private ResultSet dbresult;
DbConnect(){
dbconn = null;
dbstate = null;
dbresult = null;
}
public void print(String str){
System.out.println(str);
}
//连接Mysql数据库
public boolean dbConnection(String host,String port,String dbaName,String usName,String psw){
String driverName = "org.git.mm.mysql.Driver";
String dbHost = host;// 数据库的一些信息
String dbPort = port;
String dbName = dbaName;
String enCoding = "?useUnicode=true&characterEncoding=gb2312"; //解决MYSQL中文问题,要连续写 不能有空格
String userName = usName;
String Psw = psw;
String url = "jdbc:mysql://"+dbHost+":"+dbPort+"/"+dbName+enCoding;
try
{
Class.forName(driverName).newInstance();
dbconn = DriverManager.getConnection(url,userName,Psw);