我正在制作库存管理计划。问题是我正在使用存储过程的多个SQL查询。这是这样的:
try
{
CallableStatement c= m.XC.prepareCall("{call addCategory_Combobox}");
ResultSet rs = c.executeQuery();
while(rs.next())
{
String name = rs.getString("category");
jComboBox2.addItem(name);
}
rs.close();
c.close();
}
catch(Exception ex)
{
System.out.println(ex.toString());
}
这是我到目前为止所做的连接:
public class MyConnection
{
Connection XC;Statement ST;
public MyConnection()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
XC=DriverManager.getConnection("jdbc:odbc:signupcon", "sa", "123");
ST=XC.createStatement();
}
catch(Exception ex)
{
System.out.println(ex);
}
}
}
问题是当我第一次运行代码时,它会成功执行。但是当我第二次运行相同的代码时。它会收到以下错误:java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt
这是SQL查询代码:
create proc addCategory_Combobox
as
begin
Declare @Status varchar(max)
select category from Category
SELECT @Status as result
end
go