Resultset 2 « Resultset « Java Database Q&A





2. ResultSet Question    coderanch.com

3. problem with resultset in reference with my previous post    coderanch.com

Hi All!! Thanks for ur concern in solving out my query. as u asked for the code, i don't know how best i can represent it to u, as it's very easy easy to get confused with the project specific intricacies & database details. one or two three things i would like to tell u 1. i don't what do u ...

4. problem with resultset in reference with my previous post    coderanch.com

Hi All!! Thanks for ur concern in solving out my query. as u asked for the code, i don't know how best i can represent it to u, as it's very easy easy to get confused with the project specific intricacies & database details. one or two three things i would like to tell u 1. i don't what do u ...

5. HOW TO USE ResultSet.insertRow() ?    coderanch.com

6. ResultSet Paging --- I am STUCK!!!!!!    coderanch.com

Originally posted by pavi kavi: Hello Dharmesh, I have done it for many modules. there are 2 ways to obtain it 1.u can take whole result set & display only those u want 2.u can take only those which u want to display let me know which one u want.I can help u out in both cases. Pavithra

7. MSSQL7.0 resultset bug?    coderanch.com

8. Displaying resultset in many pages    coderanch.com

The least resource-intensive way is of course to make sure the database returns exactly those records you want to show. To retrieve n records, numbers k to l inclusive (i.e. l-k=n-1): Oracle: SELECT fields FROM tables WHERE condition AND ROWNUM BETWEEN k AND l ORDER BY order ASC SQL Server: SELECT TOP n fields FROM tables WHERE condition AND ...

9. ResultSet in Java    coderanch.com





11. ResultSet object    coderanch.com

12. sorting a resultset    coderanch.com

13. ResultSet check...    coderanch.com

try { String sql = "SELECT emp_fname, emp_lname FROM emp where emp_lname = ?"; PreparedStatement s = null; ResultSet r= null ; s = sconn.prepareStatement(sql); s.setString(1,"Hanks"); r =s.executeQuery(); while (r.next()) //or if(r.next()) if you only want a single row { System.out.println(r.getString(1)); System.out.println(r.getString(2)); } r.close(); s.close(); sconn.close(); } catch(SQLException e) { System.out.println("SQLException: " + e.getMessage()); e.printStackTrace(); } catch(Exception e) { System.out.println("General Exception: ...

14. Multiple ResultSets, but how many?    coderanch.com

15. Dis-connected resultset    coderanch.com

16. ResultSet object from executeUpdate()    coderanch.com





17. ResultSet problem    coderanch.com

something doesn't seem right here. This is what you are doing (whether you know it or not) //query the database //say 10 matches while (more records) { extract field1 //will do this 10 times } //finished processing the 10 rows extract field2 //which one?? there were 10 rows returned??? //there is also an error here because the //resultset is at the ...

18. ResultSet    coderanch.com

Hi. If a user keys in a postal code that is not in the table, I want an error message to come back stating this. My problem is that I can't seem to figure out how to tell if my select statement didn't find anything. Is there a method I can use that is sort of like a getRowCount? I've tried ...

19. copying resultset objects    coderanch.com

20. OutOfMemoryError when using ResultSet    coderanch.com

My problem: I have an input textfile of 1000 records (1000 lines) consisting of birthdate, personal id number and geographic location number. I am to produce an output textfile by joining the input records with data in a database table (Sybase ASE 12.5 database, I connect to it with JDBC driver: JConnect5) of 5 000 000 rows plus (most or all ...

22. ResultSet Thru ResultSet    coderanch.com

I have a result set rs. Depending on some value from rs i wanna get another resultset rs2with diff query. How to do this? I ve code like this Connection con1=DriverManager.getConnection(URL); Statement stmt1 = con1.createStatement(); String qry="SELECT PONumber FROM Order"; ResultSet rs= stmt1.executeQuery(qry); try { while (rs.next()) { Statement stmt2 = con1.createStatement(); String qry2="SELECT BuyerName FROM Order where PONumber='"+rs.getString("PONumber")+"'"; ResultSet rs2= ...

23. Paging Resultset    coderanch.com

24. who is implementing ResultSet    coderanch.com

You register a driver using Class.forName(...) (actually, that line allows the driver to register itself), then when you call DriverManager.getConnection(...), the DriverManager looks at the drivers it knows about and returns one that will handle the given database URL. Everything from this point is done via interfaces. There are concrete classes behind these interfaces, but it is better to treat them ...

25. help whit ResultSet    coderanch.com

Hi, I need help for the next methods (first(),last(),absolute())because dont work and send me this error in import java.sql.*; public class Query { public static void main(String[] args) { try { Class.forName("org.gjt.mm.mysql.Driver").newInstance(); } catch (Exception e) { System.err.println("Driver Error..."); e.printStackTrace(); } try { String cadCon="jdbc:mysql://127.0.0.1/xxx"; Connection conexion = DriverManager.getConnection(cadCon,"xx ","xx"); Statement sentencia = conexion.createStatement(); String consulta="SELECT * FROM bajas"; ResultSet srs ...

26. ResultSet Question    coderanch.com

27. problem in extracting values from ResultSet    coderanch.com

I'm writing more of my code to make myself clear the structure of the table is TRANS_NO NOT NULL VARCHAR2(4) STUD_ID VARCHAR2(6) F_PATH VARCHAR2(100) F_NAME VARCHAR2(50) F_FILE BLOB F_SIZE VARCHAR2(10) TRANS_DATE DATE A_TYPE VARCHAR2(1) F_ACCESS VARCHAR2(4000) F_DUPLICATE NUMBER(3) and the code is:-- cmd="select trans_no,stud_id,f_name,f_size,trans_date,f_access from transaction where a_type='S'"; rs=stmt.executeQuery(cmd); rs.next(); String a=rs.getString("f_access"); System.out.println(a);///I checked the value here of a is "333" ...

28. JDBC - ResultSet- Pls help    coderanch.com

Hi.... I need the following information on ResultSet very urgently. can someone pls help me or let me know where can I get this info? 1). We can use SetFetchsize() to datasize to be retrieved from Result Set at one shot. When we use SetFetchSize(1024) and the there are only 10 records in ResultSet, what is the impact? 2). If we ...

29. ResultSet Question    coderanch.com

There's two basic problems with your code, I think. One is that it's very dodgy to just string two select statements together like that. There's no guarantee what the database will do with it. I'd suggest doing each of the two selects as a separate query with a separate resultset. The second problem is that you need to quote the names ...

31. Problem in running one resultset into another    coderanch.com

I was trying for the following code but it runs one time and gives error after tha: Statement st1 = conn.createStatement(); Statement st2 = conn.createStatement(); ResultSet rs1 = st1.executeQuery("select client from clienttable"); ResultSet st2=null; while(rs1.next()) { String cl = rs1.getString("client"); rs2 = st2.executeQuery("select subclient from subtable where client='"+cl+"'"); if(rs2.next()) { //do something } } it runs for one time and than ...

32. returning a ResultSet?    coderanch.com

things can get very messy if you start to throw ResultSets around, especially between classes or on high traffic applications. Your objective should be to minimize stress on the database, so you should have a "get in, and get out" type attitude. As mentioned above, store it in an object/collection that best suits your needs to process the results. Jamie

33. How does the Resultset Interface work    coderanch.com

34. Resultset and Pageable print method    coderanch.com

Hello, I am trying to use a resultSet returned from an Oracle database in conjunction with the Print method of the Pageable class. Using the resultSet within the Print method is not suitable as the method requires "drawing" types such as graphics. Has anybody faced this problem or could help me with a solution? Thanks, Mark

35. How to select resultset in range?    coderanch.com

Can you explain a little more what you're trying to do? It seems a little odd that you need to select rows 3-5 in a table like that. Isn't there a specific field value(s) you can add to your WHERE clause to identify the records you need? Sorry, maybe I'm just misunderstanding you :roll:

36. clarify updateInt method in ResultSet    coderanch.com

39. JDBC ResultSet Applet issue    coderanch.com

40. ResultSet    coderanch.com

41. Using ResultSet    coderanch.com

Hi everyone, I am using ResultSet to slect data from my database and displaying it on a textArea. The problem is that, it's only displaying one row only so I don't know how I can make it display all the rows. The section of code that is retrieving the data is: try{ rs2 = stat.executeQuery(select2); while(rs2.next()) { stat = con.createStatement(); String ...

42. a simple question about "ResultSet"    coderanch.com

43. Multiple Use ResultSet    coderanch.com

Is there a way to use or make a ResultSet object be used many times? I understand once a result set object has been used up i.e. up to rs.next()==false, it could no longer be used by another method to access its contents. To access such contents again, a new result set object need to be created. I have been using ...

44. Processing of Multiple Resultset    coderanch.com

45. my resultset return what????    coderanch.com

it depends on your query. If you use "select count(*) from ..." it will always return at least a 0. If in fact you have a "select column1, ... from XX ..." then rs.next() will never be true when no matches are found in the database unless your driver your driver is not even close to being JDBC compliant. Also, verify ...

46. getting ResultSet from Java Stored Procedure    coderanch.com

Hi, I'm running a Java Stored Procedure on an Oracle Database. I want to call the Stored Proc. from a Java application. I'm able to do so and return values, however I want to be able to return a result set. Is this possible in Java Stored Procedures? If so, do i have to use Oracle Cursors? I thought about having ...

47. ResultSet - capacity?    coderanch.com

This is an implementation detail of the JDBC driver. Drivers will generally not try to read the entire result set in one go -- after all, result sets might be very large and you'd run out of memory. Most do not normally fetch one record at a time either -- the network overhead to the database server would be prohibitive. What ...

48. JDBC ResultSet    coderanch.com

I've got a question for JDBC specialists. When you perform an executeQuery on a Statement like this : Results rs = s.executeQuery("select ... where ..."); Is the ResultSet populated with ALL the rows from the query in one shot, or is it populated "on demand" when you perform a rs.next(); My understanding is that only JDBC 2.0 Scrollable Resultset offers the ...

49. incorrect resultset being returned    coderanch.com

Hi, I have a thread that wakes up every 30 secs and does a call to the database to get the files that are new and need to be processed. We use a mysql database running on win2k. the field that we use as a flag is a tinyint unsigned field. occasionally when the following code is executed it disregards the ...

50. JDBC ResultSet Paging[URGENT]    coderanch.com

Couple ways to do this... 1) Cache your data set and hold it in memory somewhere, which avoids hitting the database for each page that you need. http://www.javaworld.com/javaworld/jw-02-2001/jw-0202-cachedrow_p.html 2) If you have MySQL you can use SQL: SELECT* FROM Some_Table ORDER BY Some_Column ASC LIMIT 3,5 (where 3 = the first element you want to display indexed from 0, and 5 ...

51. Passing ResultSet around    coderanch.com

Simon is suggesting decoupling your UI from any knowledge that it's working with a database - in your case, by leaving the ResultSet/connection/statement open so that you can return your resultset, you are effectively making the UI responsible for knowing that it has to close the ResultSet to free up a database connection. Bad idea. Instead, Simon suggests copying the resultSet ...

53. Problem with resultset FetchSize() method    coderanch.com

I am making call to stored procedure.I have set the fetchsize of result set to 1000.Even though the size is set , for first fetch only 10 records are fectched which is default size and for next fetch 1000 records are returned. I am using Tomcat web server and oci driver. Can anyone pls help me i need all 1000 records ...

54. resultset    coderanch.com

55. resultset    coderanch.com

56. Large ResultSet    coderanch.com

I have a query that returns anywhere from 1000 to 5000 rows. I have to show them to one screen (no paging). What are the ways in which i can get the best time performance. Let me know what i can do at Database, Server or whats the best Java technology that would gimme the best performance.

57. ResultSet question    coderanch.com

58. How to obtain a resultset using a stored procedure    coderanch.com

I thankful to you all. Avi,I want to ask you a question ,suppose (SQL Server is the database or it can be any ,but in my case it is SQL-Server) i am firing more then one Select statement. Then How would I proceed,suppose I want to proceed with the third select statement of Stored procedure and don't want to operate on ...

59. efficient parsing of the resultset    coderanch.com

60. Quering the ResultSet    coderanch.com

61. Compare 2 Resultsets    coderanch.com

62. ResultSet Problem    coderanch.com

Hi, I am pulling my hair with such great frustration with this problem I having and I hope someone here could shed some light upon me. I am using jdbc-odbc bridge connecting to an access database. In this database, I have a table which has to fields, id and pid. I don't have a primary key, which is probably our problem, ...

63. ResultSet Problem (ofer)    coderanch.com

64. ResultSet Problem!!!    coderanch.com

65. Question about getLong() of ResultSet    coderanch.com

66. getting recordCount from ResultSet object ?    coderanch.com

While this is mostly a matter of personal preference, I prefer using #1 or #3 depending on the scenario. If I would be making the query anyway, I would use #1. If I'm not making the query anyway, I would use #3. I try to avoid doing the same query twice. I do agree with David that the overhead isn't so ...

67. Resultset Paging    coderanch.com

68. returning resultsets    coderanch.com

70. cannot get resultset correctly through jdbc    coderanch.com

Hi, I have the following problem for some time now. Has anyone had such problem before and solved it? Pls. help. The resultset returned from: con = getConnection(); stmt = con.prepareStatement(strSql); stmt.setString(1, userid); stmt.setString(2, corp); ResultSet rs = stmt.executeQuery(); while( rs.next() ){ ... } is empty but using the same sql can get result from sqlplus. The sql is select distinct ...

71. ResultSet.getBytes()    coderanch.com

72. about ResultSet    coderanch.com

73. Delay in JDBC ResultSet    coderanch.com

No, this is misleading. You're probably not waiting for "Java processing" here; you're really waiting for (a) the DB, and (b) the network. Just because a ResultSet object has been returned, that does not mean that all the data has been received from the DB. (Even though it might look that way.) Instead, a ResultSet is typically still associated with the ...

75. the workings of ResultSet.getFetchSize()    coderanch.com

Hello, I have a method which looks something like this: protected ResultSet queryResultsRS( String database, String sqlQuery ) throws SQLException { Connection conn = connect(database); Statement stmt = conn.createStatement(); ResultSet resultSet = stmt.executeQuery(sqlQuery); System.out.println(resultSet.getFetchSize()); return(resultSet); } The validate method does the following to return an int: return( queryResultsRS("userDB","SELECT ClientID, CorporateID, LoginCounter FROM user_info WHERE EmailAddress = '"+emailAddress+"' AND LoginPassword LIKE BINARY ...

76. state of ResultSet    coderanch.com

77. how to refresh resultset    coderanch.com

hi guys, i get an updatable resultset from a connection then used it to insert a new row but the result set doesn't chane after insertion, i mean the no of rows before insertion is the same after insertion and also the data, this is the code prove what i say int currentRow = resultset.getRow(); display(resultset); resultset.moveToInsertRow(); for (int i = ...

78. ResultSet Problem    coderanch.com

Statement stat = con.createStatement("select * from Employees where employee_id = 106"); ResultSet res = stat.excuteQuery(); String s = res.getString(1); // Returns a String object that encapsulates the String literal "Robert". String a = "Robert"; if ( a.equals(s) ) { // some code executes } else { // some code executes } Even though 's' is a reference to a String object ...

79. Resultset Problem    coderanch.com

80. getChar() in Resultset    coderanch.com

81. hi all problem in resultset    coderanch.com

Without seeing specific code, I can only give you some general advice. Limit the sql query to not return so much data by adding more to the where clause or by setting a row limit on the results returned. Additionally for large result sets, try to get all your processing done inside the resultset loop so that you don't have to ...

82. ResultSet randomizing    coderanch.com

83. checking resultset    coderanch.com

hi, i have a problem with the Resultset. I read the resultset with getString(0 or getInt() method. but then i need to check that results for some condiions.I tried stroring all the values in array and arryalist. but if i have 5 cols then i have to create 5 arrays. I think thats not the efficent way to do this. Does ...

84. Using Resultset    coderanch.com

I have found that I can add a new Record to the Record set by using the InserRow() method but I am running into an interensting problem in that the Database has an AutoIncrement field as the ID and as a result I cannot write to that field without the program crashing. But I also cannot not write to the field ...

85. code being blocked by ResultSet.execute    coderanch.com

guys, have you had your code being blocked by a call to ResultSet.execute(sql)?? some times, when someone is locking some resource in the data base and I try to use the same resource the Data base puts my request in a stack to wait unitl some one releases the resource, and my application gets unaccesible? Any sugestions to solve the problem? ...

86. Something wrong in returning ResultSet    coderanch.com

The biggest problem is that it becomes very difficult to clean up your resources. There are two separate issues. First, you have to make sure that every place where this method is called, once the ResultSet is fully processed, that "close()" is called. If you are writing all of the code that access this method, then you have control over that. ...

87. ResultSet issue!!!!!!!!    coderanch.com

88. Where does the ResultSet reside?    coderanch.com

89. Using FOR loop to loop in a resultset    coderanch.com

for(int iIndex=0;iIndex

90. ResultSet problem    coderanch.com

91. Storing The ResultSet    coderanch.com

Hey Guys me again! Here I'm trying to store the sole result into a string called ans, and use the string in another query. as dar as i can tell the ans string isn't getting any values? Can anybody shed some light on this? Thanks guys. <% Connection con = null; try{ Class.forName("oracle.jdbc.driver.OracleDriver"); con=DriverManager.getConnection("jdbc :-o racle:thin:@witnt07.wit.ie:1521 :-o rawit","x", "x"); Statement st=con.createStatement(); ...

92. Resultset Problem ,Please help    coderanch.com

Hi All, I am trying to create new class in Eclipse and trying to insert a value in the DB from java.I am not able to fetch the the resultset .I have been working all these days. I can fetch and update in other tables.Whatever table I create today,I am not able to perform anything.Pl.help.The code is as follows. I get ...

93. Please help with the resultset problem    coderanch.com

Hi all , I am trying to find if a particular string is available in a String using 'instr' function..I dont get the output.The line rs= pstmt.executeQuery is not functioning.Please help me out public int checkFiles(int acuserid,String fileid,String files) { ResultSet rs = null; PreparedStatement pstmt = null; int userid=0; System.out.println("Hai"); try { String sql = "select instr(\'"+files+"\',\'"+fileid+"\',1) from clientinfonew where ...

94. Resultset doubt    coderanch.com

95. ResultSet needs boolean??????    coderanch.com

96. Need a disconnected resultset    coderanch.com

Using java and oracle. I want to build a java data layer that allows business layer to specify name of stored procedure to invoke. The data layer should return something like a disconnected resultset to the business layer. Problem: OracleCachedRowSet is very limited - it must be given a select against a single table. Seems to eliminate OracleCachedRowSet for generic usage. ...

97. JDBC ResultSet    coderanch.com

no. A fetchsize is used for caching more or less results. Of course, if the database supports 'fetchsize', there might not be much use in a fetchsize < 2. But since it isn't build for counting results, I wouldn't like to stick on it. At least I would read the documentation of fetchsize very carefully - Perhaps the fetchsize is allways ...

98. Accesing ResultSet    coderanch.com

I've a scenario where i've to pass same resultset to two methods. Iam thinking of following two options 1) once the first one is done, call beforefirst on resultset, so that it can start all over again 2)close the statement,and create a new statement and execute query again and use the fresh resultset Please let me know which has less performance ...

99. Problem withUpdatable Resultset    coderanch.com

100. ResultSet    coderanch.com

To add a little to the previous response, when dealing with a Statement, there are three types of execute methods: 1) "executeQuery()" is used for doing a SELECT statement, and will return a ResultSet. 2) "executeUpdate()" is used for doing a DELETE, UPDATE or INSERT statement, and will return an int (number of rows affected). 3) "execute()" is used for multiple ...