Here's my current SQL statement:
SEARCH_ALBUMS_SQL = "SELECT * FROM albums WHERE title LIKE ? OR artist LIKE ?;";
It's returning exact matches to the album or artist names, but not anything else. ... |
I'm trying to use the prepareStatement function. The code is below. After it executes, it returns me a bunch of string 'vlicense' instead of the the values. When the code finishing ... |
I'm new to using JDBC + MySQL.
I have several 1/0 values which I want to stick into a database with a PreparedStatement. The destination column is a BIT(M!=1). I'm ... |
I'm placing and image into a databse, it could be eitehr an MYSQL database (the Server) or an SQLITE database (a Tablet PC for on the road). The Java application synchs ... |
I have the following Java code:
String query = "Select 1 from myTable where name = ? and age = ?";
PreparedStatement stmt = conn.prepareStatement(query);
stmt.setString(1, name);
stmt.setInt(2, age);
ResultSet rs = stmt.executeQuery();
Whenever I run the ... |
I'm trying to figure out if it's efficient for me to cache all of my statements when I create my database connection or if I should only create those that are ... |
I recently have began using prepared statements again in a web application, and I know that it is discouraged to use prepared statements for all the transactions. What I do not ... |
|
From what I understand, MySQL 5.1 supports server-side prepared statements. Therefore the following code should prepare the statement once, and execute it 10 times:
Connection conn = ds.getConnection();
...
|
I have 3 buttons (add, save, cancel). If I press the add button, it automatically generates an auto-incremented value and is displayed in a text field. If I press the save ... |
I have this code:
Date start = new Date(Integer.parseInt(jTextField4.getText()), Integer.parseInt(jTextField16.getText()), Integer.parseInt(jTextField17.getText()));
Date end = new Date(Integer.parseInt(jTextField5.getText()), Integer.parseInt(jTextField18.getText()), Integer.parseInt(jTextField19.getText()));
...
|
When I use the code below in a prepared statement
Date totalDate = visit.getTotalTime();
Date visitDate = visit.getVisitTime();
java.sql.Time sqlTotalTime = new java.sql.Time(totalDate.getTime() - visitDate.getTime());
ps.setTime(4, sqlTotalTime);
And I use these values
08/Dec/2010:07:27:54
08/Dec/2010:07:27:52
I would expect 00:00:02 ... |
I'm executing a few SELECTs in a row and I'm wondering how I should handle the PreparedStatements.
Example code:
//Connection conn is already declared
PreparedStatement pstmt = null;
ResultSet rset = null;
try {
String ...
|
I wrote following java method and when I call it, gives me the error
Parameter index out of range (2 > number of parameters, which is 1).
Can anyone please explain me what's ... |
I'm using an "insert or update" query such as the one below:
String sql =
...
|
Having issues with this the one that needs to be set is a auto increment integer so how would I Specify that
PreparedStatement stmt = conn.prepareStatement("INSERT INTO `"+OnlineUsers.table2+"` VALUES (?,?,?)");
...
|
I have made a java class which runs in it's own thread that works through a queue of mysql queries so that it doesn't block the main application thread. I want ... |
I am using prepared statements to execute mysql database queries. And i want to implement a search functionality based on a keyword of sorts. For that I need to use "like" ... |
hi all, i want to use the getLastInsertID() of mmMysql Driver because according to the author it is thread safe. in the documentation it was stated that i need to cast my prepared statement to org.gjt.mm.mysql.PreparedStatement inorder to use this specific function. how can i do it? i tried several statements but i can't get it right. pls. help. or if ... |
|
|
|
Hi Guys... I am new here. I was looking for a JDBC section in this forum, couldn't find one and this particular section seems the closest to what I was looking for, so I am posting here. I am listing down the full source code here: Java Code: import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import javax.annotation.Resource; import javax.servlet.ServletException; import ... |
And the test code to get the qtt_games is : conn = DriverManager.getConnection (url,user,pwd); byte bcode[] = poscode.getByteArrayCode(); // bcode is inserted ok in another preparedstatement... String query = "SELECT qtt_games FROM positions "+ "WHERE poscode=? and iswturn=?"; PreparedStatement pstmt = conn.prepareStatement(query); pstmt.setBytes (1,bcode); pstmt.setByte (2,poscode.getIsWhiteTurn()); //it returns a byte ResultSet rs = pstmt.executeQuery (query); When pstmt.executeQuery is reached, it's thrown ... |