我在连接到mySql和创建表等时遇到问题......
WEB_ING / lib: javax.servlet.jsp.jstl-1.2.1 javax.servlet.jsp.jstl-API-1.2.1 MySQL的连接器的Java-5.1.22槽
我(总是得到这个堆栈跟踪/错误:
org.apache.jasper.JasperException: An exception occurred processing JSP page /hallo.jsp at line 38
35: String QueryString = "CREATE TABLE RandomData ( id integer, birth_date date, salary integer, name char(10))";
36:
37:
38: int result = stmt.executeUpdate("CREATE TABLE RandomData ( id integer, birth_date date, salary integer, name char(10))");
39:
40: System.out.println(result);
41:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.lang.NullPointerException
org.apache.jsp.hallo_jsp._jspService(hallo_jsp.java:103)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
这是我的代码:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@page import="java.util.*"%>
<%@page import="java.sql.*"%>
<%@ page import="java.io.*" %>
<%
int rows = 1000;
int comn = 1000;
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = null;
ResultSet rst = null;
Statement stmt = null;
try{
String url = "jdbc:mysql://BERTMAC-PC:3306/eDocs";
con = DriverManager.getConnection(url,"enternet","enternet");
stmt = con.createStatement();
}catch(Exception e){
e.printStackTrace(new PrintWriter(out));
System.out.println(e.getMessage());
}
int result = stmt.executeUpdate("CREATE TABLE RandomData ( id integer, birth_date date, salary integer, name char(10))");
System.out.println(result);
rst.close();
stmt.close();
con.close();
%>
感谢您的帮助