-1

クライアントからフィードバックを受け取り、MYSQLデータベースに保存する必要があるプレーンなJSPWebページを開発しています。

ローカルホストで実行している間、Apacheサーバーのデータベース接続は正常に実行されますが、EATJ.comでページをホストした後、データベースが期待どおりに更新されないため、以下のコードについてサポートを受けられますか?

コード:

<body>
 <%@page import="java.sql.*"%>

 <%
 String name=request.getParameter("name");
String email=request.getParameter("email");
String comment=request.getParameter("comment");
try{
String connectionURL = "jdbc:mysql://localhost:3306/pizza"; 

ResultSet rs=null;
Connection con= null; 
Class.forName("com.mysql.jdbc.Driver").newInstance(); 
con = DriverManager.getConnection(connectionURL, "prakashd22", "*******");
Statement st = con.createStatement();
String sql = ("INSERT INTO feedback VALUES ('" + name + "','" + email + "','"+ comment +"') ");
st.executeUpdate(sql);
rs.close();
st.close();
con.close();
}
catch(Exception e){out.print(e);}
%>
<jsp:include page="feed.jsp" />
</body>
</html>
4

2 に答える 2

0

更新ステートメントを実行している間、nullのResultSetオブジェクトが邪魔になっているように見えます

rs.close();

コードを分離しておく方が賢明です。

于 2012-10-12T07:42:44.407 に答える
0

次のことを確認します 1)com.mysql.jdbc.Driverが存在するかどうかを確認します

2)String connectionURL = "jdbc:mysql://localhost:3306/pizza"データベースがローカル マシンに存在するかどうか

3) データベースがリモート サーバー上にある場合、GRANTこのデータベースへのアクセス許可が必要になる場合がありますhttp://dev.mysql.com/doc/refman/5.1/en/grant.html

そしてスタックトレースお願いします!! お役に立てれば!

于 2012-10-12T08:38:32.340 に答える