这段jsp代码中数据库建表部分没有执行,为什么呀
<%@ page import= "java.sql.*,com.book.jdbc.* "%>
<%@ page language= "java " isErrorPage= "true " contentType= "text/html; charset=gb2312 " %>
<%@ page import= "java.io.* "%>
<%@ page import= "java.util.* "%>
<%@ page import= "javax.servlet.* "%>
<%@ page import= "java.lang.* "%>
<%@ page import= "java.awt.* "%>
<html>
<head>
<title> SQL Server数据表创建示例 </title>
</head>
<body>
<center>
<h3> SQL Server数据表创建示例 </h3>
<%Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
String url= "jdbc:odbc:new ";
String user= "sa ";
String password= " ";
Connection conn=DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql= "create table goodscategory( "+ "id number primary key, "+ "categoryName varchar(100), "+ "categoryDescription varchar(200)) ";
try{
stmt.execute(sql);
out.println( " <p> 成功创建数据表goodscategory. </p> ");
}catch(Exception ex){
ex.printStackTrace();
}
%>
<%
stmt.close();
conn.close();
%>
<%out.print( "数据库操作成功,恭喜你 ");%>
</center>
</body>
</html>
------解决方案--------------------stmt.executeUpdate(sql);
------解决方案--------------------如楼上所说
stmt.execute(sql);===> stmt.executeUpdate(sql);
------解决方案--------------------stmt.execute(sql)改成stmt.executeUpdate(sql);