java.sql.CallableStatement cstmt = null;
cstmt = conn.prepareCall("{ call " + tableName + " }");  //注意花括号的位置及空格
cstmt.execute();

解决方案 »

  1.   

    假如这样创建一个存储过程。
    CREATE PROCEDURE sp_getStudentByName(@name char(10))
    as
    Select * from Students where Name=@name
    这样调用
    DbObject DbO = new DbObject(new SqlServerConnectionFactory("localhost",      1433, "demo", "sa", ""));
     Connection con = DbO.getConnection();     CallableStatement pstmt = null;System.out.println("TestDB1()............");
    pstmt = con.prepareCall("{call             sp_getStudentByName(?)}");    //注意参数如何传递
     pstmt.setString(1, "Tom"); 
    }
    使用的是SQLServer。
    更详细的自己看看java方面的书吧