0

mySql への接続やテーブルの作成などに問題があります...

WEB_ING/lib : javax.servlet.jsp.jstl-1.2.1 javax.servlet.jsp.jstl-api-1.2.1 mysql-connector-java-5.1.22-bin

私(私は常にこのスタックトレース/エラーを取得しています:

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();


    %>

助けてくれてありがとう

4

0 に答える 0