twin yan wrote:ok so if i get this right
let's say my line is
i will have only one pst.set command after it ?
so for every "?" i will have a pst.set ?
almost you do not need to include the ' in your varchar variables, so statements that work with lots of varchars are a LOT LOT easier
so you will need 2 pst.set
pst.setDouble // these are off the top of my head and may not be the correct method names
the content of bid as a string ?
twin yan wrote:still doing the same thing , what's the diffrence between with ' and without it worked both ways
any ideas on what's wrong with my prepared statment ?
Ok ' are for strings, you are making something convert a striping to an Integer when it isn't required.
The syntax of your prepared statement looks fine to me, so we must start looking at other areas of concern.
I can see a few possible problems
1) does the select return data? You just say result.next Without first checking there is a row returned.
2) if date1 is a database date field just inserting a java default formatted date string could cause problems, much better to also make that a prepared statement then you can use the setDate method which is multi date format safe.
3) what values are returned from the select statement? Pop them into debugging statements to check the values, are they what you expect?
4) in your catch block simply use e.printStackTrace as that shows up red where ever the console output goes. You do know where console output goes?
Also, I don't know the details of MySQL concurrency model, but allocating a new ID by selecting the maximum ID first and incrementing that may fail in multiuser environments - if two people happen to execute this code at exactly the same time, they may end up using identical ID for the new record. Hopefully a primary key constraint would prevent that, but if you use auto increment column in MySQL, the database can allocate new IDs for you, in a way which is both more effective and safe in multiuser environment.