Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,959
    Thanks
    120
    Thanked 76 Times in 76 Posts

    mysql stored function ,cs = con.prepareCall, ERROR

    all my stored procedures are working fine, but functions: example


    Code:
       CallableStatement cs;
       java.sql.Connection con = getConnection();
       // at this point error popps up
       cs = con.prepareCall("{? = call " + functionName + "(?,?,?,?,?)}");
    [ERROR]
    "java.lang.NumberFormatException: For input string: "1)
    ... stuf that is the copy of stored function
    [/ERROR]

    MYSQL function, which direct in mysql query analyzer works just fine:


    Code:
    DELIMITER $$
    
    DROP FUNCTION IF EXISTS `test`.`addMember` $$
    CREATE FUNCTION `addMember`(c_nick VARCHAR(15),
                                c_pwd VARCHAR(40),
                                c_email VARCHAR(100),
                                c_unique_id VARCHAR(40),
                                c_ip_value long
                                ) RETURNS varchar(1)
    BEGIN
    
      DECLARE countryCode2 INT;
    
      #duplicate entry#
      DECLARE EXIT HANDLER FOR 1062 return '-1';
      #za vse ostale nepredvidene fore#
      DECLARE EXIT HANDLER FOR SQLEXCEPTION return '-2';
    
    
      select cc2 into countryCode2 from Imported_data_ipToCountry where ip_from < c_ip_value and ip_to > c_ip_value ;
    
    
      INSERT INTO MEMBER (nick,pwd,email,ip_to_country,reg_unique_id,osp,dsp)
      values(c_nick,c_pwd,c_email,countryCode2,c_unique_id,user(),now());
    
      return '0';
    
    END $$
    
    DELIMITER ;
    had originaly; RETURNS int(11), but result was the same.

    thanks for any help.

  • #2
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,959
    Thanks
    120
    Thanked 76 Times in 76 Posts
    replaced now() with CURRENT_TIMESTAMP and now miraculously works.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •