Jump to content

JDBC statement problem

- - - - -

  • Please log in to reply
5 replies to this topic

#1
mith

mith

    Newbie

  • Members
  • PipPip
  • 18 posts
Hello !
Im trying to make an application that can cooperate with database i made and i get this problem which works in each my class but in one i get SQLException: [h=1]ORA 00917 Missing a comma[/h]
my statement:

static Statement stmt;
String insertString1 = "insert into SALARY values("+i+" , "+s1+" , "+s2+" , '"+s3+"' , "+s4+",)";
stmt.executeUpdate(insertString1);

where i,s1,s2,s4 are integer and s3 is varchar

can any1 tell me where the hell i have to put this comma??!?!?!

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
You have an extra comma before the )

You should also probably specify the fields before your VALUES clause.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
mith

mith

    Newbie

  • Members
  • PipPip
  • 18 posts
with:
String insertString1 = "insert into WYNAGRODZENIE values("+i+" , "+s1+" , "+s2+" , '"+s3+"' , "+s4+")";

problem is the same...

#4
lethalwire

lethalwire

    while(false){ ... }

  • Members
  • PipPipPipPipPipPipPip
  • 748 posts
  • Programming Language:Java, PHP
  • Learning:Java, PHP

Quote

String insertString1 = "insert into WYNAGRODZENIE values("+i+" , "+s1+" , "+s2+" , '"+s3+"' , "+s4+")";
^^^ That one looks a bit different from the rest.

#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
static Statement stmt; String insertString1 = "insert into SALARY (field1,field2,field3,field4) values("+i+" , "+s1+" , "+s2+" , '"+s3+"' , "+s4+")"; stmt.executeUpdate(insertString1);
Also, what is the value of i, s1, s2, s3, and s4? If there are single quotes in those, it'll scramble things up.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#6
mith

mith

    Newbie

  • Members
  • PipPip
  • 18 posts
for example
i = 1
s1 = 111
s2 = 1111
s3 = 2012/01/01
s4 = 123




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users