1. Primary key from inserted row jdbc? stackoverflow.comIs there a cross database platform way to get the primary key of the record you have just inserted? I noted that this answer says that you can get it by ... |
2. Update more than one row atomically stackoverflow.comI need to execute a select and then update some of the rows in the ResultSet in an atomic way. The code I am using looks like (simplified):
|
3. JDBC query returning no rows, but interactive query does? stackoverflow.comI'm attempting to retrieve data from a SolarWinds network performance database (MS SQL 2005) and a query that works perfectly fine interactively (in the Orion database manager) returns no rows when ... |
4. Inserting multiple values in one row stackoverflow.comI need to insert data from my parsed XML file to mySQL table. Problem is that I have few attributes and don't know how to insert them in one row. I ... |
5. JDBC Lock a row using SELECT FOR UPDATE, doesn't work stackoverflow.comI am having issues with MySQL's SELECT .. FOR UPDATE, here is the query I am trying to run:
|
6. INSERT new row into database java? stackoverflow.comI have the simple following code:
|
7. Inserting a row using insertRow() method coderanch.com |
8. Query limit rows in database coderanch.com |
9. returning # of rows from sql query coderanch.comThe basic problem is that the database itself doesn't know how many rows will be returned without executing the query, or at least a good part of the query. You can get some an *estimate* of how may rows will be returned, since the optimizer computes that as part of its work to pick the best query plan. It's just a ... |
10. database row locking and update coderanch.comwhen u have multiple users trying to update a record, how do u handle it - 1. do u handle it by writing codes (multiple threading) ? 2. or do u handle it from the database side, ie.e force the database to do locking ? or do u do both 1) and 2) ? |
11. problem in updating a row in JDBC coderanch.comThe soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - ... |
12. Inserting Duplicate rows coderanch.comHi all, Ours is a WebServices application. Whenever a request comes it is first checked for duplicate transaction from the table. If a duplication transaction ID exists the request is rejected else it is processed and at the end...the record is inserted in the database. Now the problem is if 2 or more requests having same id comes at same time...the ... |
13. Update resturns zero rows updated without throwing errors. coderanch.comIn one of our application code, we are performing executeUpdate on a prepared statement object. This is done in a loop on a large number of records, say 20000. On some occasions, the update fails to update the table with relevant information and returns without throwing any errors. We need to know the reason why it is not updating the table ... |
14. How to update a row using batchUpdate? coderanch.comHI All, I am facing a problem when updating a set of rows using batch updates. Please see the code: pStmt = con.prepareStatement(MeetPointSQLConstants.MPE_UPDATE_CONTACT_INFO); System.out.println("Inside Update3"); pStmt.setString(1, mpeView.getOecContactInfo1().getContactName()); pStmt.setString(2, mpeView.getOecContactInfo1().getTelArea()); pStmt.setString(3, mpeView.getOecContactInfo1().getTelExch()); pStmt.setString(4, mpeView.getOecContactInfo1().getTelNum()); pStmt.setLong(5, asrId); pStmt.setString(6, mpeView.getOecContactInfo1().getContactTyp()); pStmt.addBatch(); System.out.println("Inside Update4"); pStmt.setString(1, mpeView.getOecContactInfo2().getContactName()); pStmt.setString(2, mpeView.getOecContactInfo2().getTelArea()); pStmt.setString(3, mpeView.getOecContactInfo2().getTelExch()); pStmt.setString(4, mpeView.getOecContactInfo2().getTelNum()); pStmt.setLong(5, asrId); pStmt.setString(6, mpeView.getOecContactInfo2().getContactTyp()); pStmt.addBatch(); pStmt.executeBatch(); Thanx in advance. [Bear edit: removed "urgent" ... |
15. inserting a row when there is a sequence in that table coderanch.com |
16. how do i insert more than one row to my table coderanch.comThere's nothing wrong with that that I can see, although clearParameters is unneeded; it should be harmless functionally and not really significant in terms of performance.. It's possible that the 2nd insert is throwing an exception, perhaps because of a constraint violation, so look at your exception logs, if you haven't. It's also possible that your driver/database is simply broken and ... |
17. Inserting multiple rows at a time in the table? coderanch.comHi Jeanne , Here is the code u asked for: public boolean createPreparedStatement(String query,HashMap params,int queryType,HttpServletRequest request) { boolean flag = false; ErrorLogger.debug("Inside createPreparedStatement() Query to be prepared is ---> " + query); //checkParametersMap(params); try { //con is the class object which gets the connection (an instance variable) //moDbConn is the Connection class object (an instance variable) moDbConn = con.getConnection(); if(moDbConn ... |
18. Insert a new row with values from an existing record coderanch.com |
19. need a query to aggregate rows coderanch.comHi- I need to accumulate records where the prime record belongs to a particular entity (manager). I need all his/her reporting managers all the way down the chain i.e. managers that report to managers...each record has a supervisor_id reflecting this relationship. Can I do this with one query by joining to table to itself? thank you |
20. need 2 rows rather than 5 from this query coderanch.comWhen I run this query, SELECT machineName, lastBackupTime, lastCompletedBackupTime, lastBackupStatus, reportingPeriod FROM VERITAS WHERE reportingperiod in ('2007-07-21-00.00.00', '2007-07-28-00.00.00') and machinename in ('bsrn70ws250') I get 5 rows -- 2 rows for 7/21/2007 reportingPeriod and 3 rows for 7/28/2007 reportingPeriod for the same machineName. MACHINENAME LASTBACKUPTIME LASTCOMPLETEDBACKUPTIME LASTBACKUPSTATUS REPORTINGPERIOD bsrn70ws250 Jul 19, 2007 6:00:00 PM Jun 27, 2007 11:58:00 PM Client computer not ... |
21. returning # of rows from sql query coderanch.com |
22. Update based on Row id coderanch.comHi Guys, I have a doubt in updating the table based on row id. I have a table which doen't have any constaints( no primary key).my requirement is in the input screen in jsp we will provide the textbox to user, he enters some kit number. then i am displaying all the rows with that kit number in the next sreen. ... |
23. need help :: multiple rows update without primary key coderanch.comHi guys, My requirement is i have to update the table where there is no primary key. the user enters the kitnumber, so we are pulling all the rows for that particular kit number.i have checkboxes for all the rows, and the value for the checkbox is the row id. when we display the results in a grid, we have to ... |
24. how to automatically detect a row insertion in database coderanch.comHi I want to an application be triggered as soon as a row is inserted in a database. I wwould like to have it happen on an event basis. That is as soon as a row is inserted an oject is created or a function is called. Is there a way to do it? Thanks utsav. |
25. Insert multiple rows in database coderanch.comHi, I need to code a program in Java with JDBC connection to ORACLE where I need to get say 200 rows from a table in database. Insert 50 more rows in the resultset and do some changes in the exisiting 200 rows (some column data) and then write it back to database. I s there a way I can do ... |
26. executeUpdate Hangs One Row Insert!!! coderanch.comHi, I am trying to call executeUpdate() on a preparedStatement.It hangs and wont give me any output.I know for sure its executeUpdate that's a problem. Help me.Even when I use the commented code it does not work! Thanks public String addUser(){ OracleCon1 db = new OracleCon1(); System.out.println(username); try{ if(db.connect()!=null){ System.out.println(password); // String query="INSERT INTO mjzeko.users (empno,username,password,accesslevel,lastlogin,preferences,dept_ID) VALUES(?,?,?,?,?,?,?)"; String query="INSERT INTO mjzeko.users ... |
27. Insert row replacing coderanch.comPlease excuse my lack of MySql knowledge here. Basically, every day I have a CSV file with a weeks worth of data. And every day that passes by, the csv files is automatically edited and removed the last day and adds the new day. So that it always has the LAST weeks data. I need to parse this data and put ... |
28. Get the current updating row, to be inserted into another table using trigger coderanch.comHello all, I have two tables, entity and entity_historical_data. I want to maintain the historical data of each entity that was updated. So, if an entity is updated 5 times, I will have five records in the entity_historical_data for the corresponding entity ID. Also, the columns in the entity and entity_historical_data are more or less the same. I am using Hibernate ... |
29. SQL query doubt about counting based on a condition and selecting rows that comply. coderanch.comHi, I am trying to fetch the Names and Ages of the users who have a maximum of 2 children between the ages stored in 'min_child_age' and 'Max_child_age' in each row. Users - ID. - Name - Age - No. of children - Min_child_age - Max_child_age - Age_child_1 - Age_child_2 - Age_child_3 - Age_child_4 I tried using the query below. But ... |
30. getting latest 100 rows inserted into table coderanch.comHi Java Ranch, I have a Requirement to display the latest 100 rows inserted into the table. In my database i have nearly 30 tables and every table will have huge amount of data in it. But every time i want to refer i need to get the latest 100 records inserted. By the way i am using MySQL as my ... |
31. Number of rows affected by sql:update coderanch.com |
32. updating rows in table error coderanch.comHello all, I'm currently working on a program to query the database, massage the returned data (ResultSet) through our business logic, then save this data back to a table (different from qry table) in the db. I'm close, but things just aren't working right. I have a couple of questions, hopefully someone can help. 1) Is there an easy way to ... |
33. Best way to insert 10000 rows in JDBC coderanch.com |
34. My sql query returns zero rows coderanch.comHi, I have written a servlet code for checking if the username is already exists in the database for registering, however my sql query returns zero rows. I have no idea of what is happening in the query. try { stmt = conn.prepareStatement("SELECT username FROM employeeinfo WHERE username=?"); stmt.setString(1, username); rs = stmt.executeQuery(); out.println("username: "+username + " Row: " + rs.getRow()); ... |
35. Select query row count (without explicit select query) coderanch.comSelect firstName, lastName from emp; (In Java) Is there any way to know the row count for above select query rather than writing separate query(select count(*) from emp)? One can calculate the count by creating count variable and incrementing it after entering resultset.next() -- true -- but I am looking for simple alternative rather than taking that route(some built in function ... |
36. Update the table rows through cursor coderanch.comSELECT ... FOR UPDATE locks the rows specified in the WHERE clause of your SELECT. The lock is released when you COMMIT or ROLLBACK the current transaction. This can be useful e.g. if you want to make sure nobody tries to update the same rows at the same time. But it can also be risky, because it is easy to lock ... |
37. Updating same rows coderanch.comHi, I would like to know best approach for concurrent updates. I have searched this forum and googled and came to following solutions: 1. Create a column lastupdatetime and use that disallow concurrent updates 2. Use Isolation level of Repeatable Read For sol1, I am not sure how it will resolve concurrent updates when you are doing bulk updates. Soln presumes ... |
38. inserting multiple rows from one table into another java-forums.org |
39. Cannot add or update a child row.... java-forums.orgHello i get this error and would appreciate some help on the matter =). 2009-jun-16 02:32:06 trav.Main saveHorseMouseClicked ALLVARLIG: null com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityCons traintViolationException: Cannot add or update a child row: a foreign key constraint fails (`trotterdb`.`horse`, CONSTRAINT `FK_horse_race` FOREIGN KEY (`Horse`) REFERENCES `race` (`RaceDate`)) I try to insert the test-data from my java program into the db when i have added foreign ... |
40. insert a row into the DB java-forums.orgim trinig to the conetion is ok... this is the code ublic void updateDataBase() { try { String query="INSERT INTO cusInfo (cusId,pass,cusName,clinetStatus,addrese,email,pho neNum,comments )values (?,?,?,?,?,?,?,?)"; ps =connection.prepareStatement(query); ps.setInt(1, getCusId()); ps.setString(2, getPass()); ps.setString(3, getCusName()); ps.setString(3, getClinetStatus()); ps.setString(4, getEmail()); ps.setString(5, getAddrese()); ps.setInt(6, getPhoneNum()); ps.setString(7, getComments()); ps.executeUpdate(); } catch (SQLException e) { // TODO Auto-generated catch block System.out.println("updateDataBase eroor"); e.printStackTrace(); } finally { try ... |
41. insert multiple rows in the table from List java-forums.orgIm trying to insert multiple new rows in the table usr_pln_rghts from the List selected items. here is my code : try { Statement stmt = connection.connection.createStatement(ResultSet.TY PE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); String[] items = queryResltList.getSelectedItems(); for (int i = 0; i < items.length; i++) { ResultSet r = stmt.executeQuery("select * from usr_pln_rghts"); r.moveToInsertRow(); r.updateString(1, items[i]); r.updateString(2, items[i]); r.updateString(3, items[i]); r.updateString(4, items[i]); r.updateString(5, items[i]); ... |
42. How to find latest inserted rows java-forums.orgHi, I am having a table where same barcodes will be inserted for a project repetetively. My problem is I want to retrieve all the barcodes for that project which are inserted latest and these barcodes are might be previously allocated or new ones or both. Searched google but found there is no function or predefined variable like rownum in mysql. ... |
43. Not able to retrieve primary key generated during insertion of row. java-forums.orgHi, I'm trying to get the primary key generated using ResultSet.getGeneratedKeys() method on Oracle 11g using JDBC code. I tried ojdbc14.jar and oddbc6.jars but still getting exception as given below: java.sql.SQLException: Invalid column type: getLong not implemented for class oracle.jdbc.driver.T4CRowidAccessor at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException (DatabaseError.java:146) at oracle.jdbc.driver.Accessor.unimpl(Accessor.java:3 58) at oracle.jdbc.driver.Accessor.getLong(Accessor.java: 496) at oracle.jdbc.driver.OracleReturnResultSet.getLong(O racleReturnResultSet.java:290) The code snippet is as follows: ... |
44. Grid for Insert rows into database forums.oracle.com |
45. Inserting rows into Access database forums.oracle.comThe database has two parts, one that holds the information a second that holds user information - user information being UserID and Password secondly i use one class logIn to connect to the database and i do a password verification then it calls my entryForm class which has the GUI interface that allows you to type in field and select different ... |
46. SQL - updating database row forums.oracle.com |
47. Insert multiple rows using sql at the same time forums.oracle.comINSERT INTO SYSTEM_USER_GROUP (ID_user_group,ID_USER,ID_GROUP) (SELECT seq_system_user_group.NEXTVAL, ID_USER, ID_GROUP, FROM SYSTEM_USER) ORA-00936: missing expression ------------>>> I think that seq_system_user_group is a scheme level of oracle, so if you select it from a table, there will not work. Thank you all the same! Can i create that sequence as a column of one table? if that is the case, then my problem will ... |