*
The moose likes JDBC and the fly likes prepareCall error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "prepareCall error" Watch "prepareCall error" New topic
Author

prepareCall error

Manu Quartier
Greenhorn

Joined: Oct 20, 2000
Posts: 10
Hello,
I have a problem with a prepareCall. When I get the value returned by the stored procedure ("statement.getString(2)"), I recieve a "null" value. Can somebody help me ?
Java code :
public static void main(String[] args) {
try {

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
Connection c;
CallableStatement statement;
ResultSet results;
c = DriverManager.getConnection("jdbcdbc:EquadisTestAvi", "sa", "");

statement = c.prepareCall("{call gfi_compt(?,?)}");

statement.setString(1, "eq_contact_id");
statement.registerOutParameter(2, java.sql.Types.INTEGER);

statement.execute();
System.out.println("cptr: " + statement.getString(2));

} catch (SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
Stored procedure :
CREATE PROCEDURE GFI_COMPT
@COMPTEUR VARCHAR(20),
@VALEUR INT OUTPUT
AS
SELECT @VALEUR = (SELECT MAX(VALEUR)+1 FROM GFI_COMPTEUR WHERE COMPTEUR_ID = @COMPTEUR)
IF @VALEUR IS NULL
BEGIN
SET @VALEUR = 1
INSERT INTO GFI_COMPTEUR (COMPTEUR_ID,VALEUR) VALUES (@COMPTEUR,@VALEUR)
END
ELSE
UPDATE GFI_COMPTEUR SET VALEUR = @VALEUR WHERE COMPTEUR_ID = @COMPTEUR
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: prepareCall error
 
Similar Threads
Does anyone know any tutorials on CallableStatement?
looking for help with datatype match
looking for help with datatype match
Please tell I'm doing something wrong and ejbs don't suck that much
Pointbase : How can I create a stored procedures with Pointbase database?