variable « Operation « Java Database Q&A





1. Using Variables to UPDATE    coderanch.com

2. updating tables using variables..    coderanch.com

4. Update D/b with Java variable    coderanch.com

6. sql INSERT using variables    coderanch.com

Jeanne Boyarsky wrote:Fred, I think what it tells you is that the examples are old. New code should use PreparedStatements (with variables) rather than Statements (with hard coding) unless there is a really good reason not to. Hard coding is vulnerable to SQL injection where a hacker can run malicious code against the database. PreparedStatements protect you against this. The JDBC ...

7. select .... where... query for a variable?    coderanch.com

Dear , I try to use prepared statements, but the examples i find are mostly using oracle but im working with MYSQL. any way i've tried this code. unfortunately it is not working! i think it can not fetch information from table in mysql. Do you have any idea what can i do? here is my code: Connection conn = null; ...

8. JDBC - Using variable in sql query?    coderanch.com

9. scanner variables into object for insertion into database.    coderanch.com

Hi all, In one class im using scanner to store information, such as forename, surname. What im trying to do is take those variables, then create a new object and pass those variables into the object, which will then store in the database. so scanner is Scanner myScanner = new Scanner( System.in ); System.out.println("Please enter first name:"); String forename = myScanner.nextLine(); ...





10. Sql query ignores variable    coderanch.com

11. Using a variable in a SELECT FROM WHERE query    java-forums.org

Use PreparedStatement to create your query. leave a '?' in place of your variable to insert. then use the method set() in the PreparedStatement class to insert your variable. There are setInt, setString, etc. for whatever type you are using. You should read up on PreparedStatement as well as all the Statement classes to see how they are used, as well ...

12. How to update with dynamic variable?    java-forums.org

It has been so long since I have used Statement; I always use PreparedStatement when I do JDBC'ing. To help out the OP in the quest for building better data accessors, Below is a complete example of using prepared statements for this update query, as well as the 'proper' handling of closing of the connection and statement objects after use. Java ...

13. insert or update from variables ?    java-forums.org

Hey everyone...I've got a little problem when I try to execute an insert statement in eclipse ... I have this database (picture 1) And an integer variable a = 500 for example what I want to do is to update table a so that instead of having the value 42 on the second row to have the value from the variable ...

14. How do I use variables in an SQL Insert staement?    forums.oracle.com

I have created two classes, GUI class and DBConnect class. i capture user input in the GUI class. I then call the insert method from the DBConnect passing parameters that I have just captured. The code for the insert method looks like something like this: public void insertData(String idno, String surname, String name) throws SQLException{ statement.executeUpdate("INSERT INTO General(IDNO,SURNAME,NAME) VALUES('"idno"', '"surname"', '"name"' ...