JSP对SQL SERVER进行数据库操作的奇怪问题~~~~
package test;
import test.*;
import java.sql.*;
public class Typebean
{
String typeid= " ";
String typename= " ";
Connection conn=null;
ResultSet rs=null;
Statement sta=null;
public Typebean()
{
String user= "sa ";
String pass= "8760747 ";
String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver ";
String dbURL = "jdbc:sqlserver://localhost:1433;DatabaseName=BookStore ";
try{
Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver ");
conn = DriverManager.getConnection(dbURL,user,pass);
sta=conn.createStatement();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public ResultSet getTypeinfo()
{
try
{
sta=conn.createStatement();
rs=sta.executeQuery( "select typename from type ");
}
catch(
SQLException e)
{
System.out.println( "捕获了 "+e.getMessage()+ "异常 ");
}
return rs;
}
public void setTypeid(String typeid)
{
this.typeid=typeid;
}
public String getTypeid()
{
return typeid;
}
public void setTypename(String typename)
{
this.typename=typename;
}
public String getTypename()
{
return typename;
}
public boolean executeInsert()
{
boolean b=false;
String sql= "insert into type values( ' "+typename+ " ') ";
try
{
sta.executeUpdate(sql);
b=true;
}
catch(SQLException e)
{
System.out.println( "捕获了 "+e.getMessage()+ "异常 ");
}
return b;
}
public static vo