Hallo Zusammen,
ich habe schon ein bissle nachgeschaut was es hier schon gibt.
Ich verstehe nicht wo das Problem liegt....
HIer mein Java Code
Hier meine Function:
Meine FehlerMeldung
ich habe schon ein bissle nachgeschaut was es hier schon gibt.
Ich verstehe nicht wo das Problem liegt....
HIer mein Java Code
Code:
private static void MSSQLServerStoredProcedureCallExample () throws ClassNotFoundException, SQLException{
String sDbDrv = "net.sourceforge.jtds.jdbc.Driver";
Class.forName(sDbDrv);
JtdsDataSource ds = new JtdsDataSource();
ds.setServerName("sql2005");
ds.setPortNumber(1433);
ds.setUser("user");
ds.setPassword("psw");
ds.setDatabaseName("dbname");
Connection con = ds.getConnection();
try {
CallableStatement callableStatement = con
.prepareCall("dbo.magalieFunction((@valueOne=?, @valueTwo=?)");
callableStatement.setInt("@valueOne", 10);
callableStatement.setInt("@valueTwo", 30);
//callableStatement.registerOutParameter("@valueOne", Types.INTEGER);
callableStatement.execute();
callableStatement.getMoreResults();
int result = callableStatement.getInt(1);
System.out.println("RESULT: " + result);
} finally {
if (con != null)
con.close();
}
}
Hier meine Function:
Code:
CREATE FUNCTION magalieFunction (@valueOne int, @valueTwo int)
RETURNS int
AS
begin
RETURN @valueOne + @valueTwo;
end;
Meine FehlerMeldung
Code:
Exception in thread "main" java.sql.SQLException: Parameter '@valueOne' not found in the parameter list.
at net.sourceforge.jtds.jdbc.JtdsCallableStatement.findParameter(JtdsCallableStatement.java:95)
at net.sourceforge.jtds.jdbc.JtdsCallableStatement.setInt(JtdsCallableStatement.java:288)
at de.pickert.db.TestDb.MSSQLServerStoredProcedureCallExample(TestDb.java:142)
at de.pickert.db.TestDb.main(TestDb.java:24)