Search Results

Search found 500 results on 20 pages for 'resultset'.

Page 1/20 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Getting the count of rows in a Java resultset

    - by Mr Morgan
    Hello Does anyone know a better way of getting the number of rows in a Java resultset returned from a MySQL database? I'm currently using this: public static int getResultSetRowCount(ResultSet resultSet) { int size = 0; try { resultSet.last(); size = resultSet.getRow(); resultSet.beforeFirst(); } catch(Exception ex) { return 0; } return size; } But am open to alternatives. The resultset returned is not going to be the total number of rows read from the database so I don;t think I can use SQL COUNT. Thanks Mr Morgan.

    Read the article

  • Building resultset using collection object

    - by Bhaskara Krishna Mohan Potam
    Hi, I had an issue in building the resultset using java. Here it goes... I am storing a collection object which is organized as row wise taken from a resultset object and putting the collection object(which is stored as vector/array list) in cache and trying to retrieve the same collection object. Here i need to build back the resultset again using the collection object. Now my doubt is building the resultset in this way possible or not? Please let me know asap. Thanks in advance, Bhaskar

    Read the article

  • Resultset (getter/setter class) object not deleting old values at 2nd Time execution in swin

    - by user2384525
    I have summarizeData() method and called so many time for value retrieve. but first time is working file but 2nd time execution value is increasing in HashMap. void summarizeData() { HashMap outerMap = new HashMap(); ArrayList list = new ArrayList(dataClass.getData()); for (int indx = 0; indx < list.size(); indx++) { System.out.println("indx : " + indx); Resultset rs = new Resultset(); rs = (Resultset) list.get(indx); if (rs != null) { int id = rs.getTestCaseNumber(); if (id > 0) { Object isExists = outerMap.get(id); if (isExists != null) { //System.out.println("found entry so updating"); Resultset inRs = new Resultset(); inRs = (Resultset) isExists; if (inRs != null) { int totExec = inRs.getTestExecution(); int totPass = inRs.getTestCasePass(); int totFail = inRs.getTestCaseFail(); // System.out.println("totE :" + totExec + " totP:" + totPass + " totF:" + totFail); int newRsStat = rs.getTestCasePass(); if (newRsStat == 1) { totPass++; inRs.setTestCasePass(totPass); } else { totFail++; inRs.setTestCaseFail(totFail); } totExec++; // System.out.println("id : "+id+" totPass: "+totPass+" totFail:"+totFail); // System.out.println("key : " + id + " val : " + inRs.getTestCaseNumber() + " " + inRs.getTestCasePass() + " " + inRs.getTestCaseFail()); inRs.setTestExecution(totExec); outerMap.put(id, inRs); } } else { // System.out.println("not exist so new entry" + " totE:" + rs.getTestExecution() + " totP:" + rs.getTestCasePass() + " totF:" + rs.getTestCaseFail()); outerMap.put(id, rs); } } } else { System.out.println("rs null"); } } Output at 1st Execution: indx : 0 indx : 1 indx : 2 indx : 3 indx : 4 indx : 5 indx : 6 indx : 7 indx : 8 indx : 9 indx : 10 totE :1 totP:1 totF:0 indx : 11 totE :1 totP:1 totF:0 indx : 12 totE :1 totP:1 totF:0 indx : 13 totE :1 totP:1 totF:0 indx : 14 totE :1 totP:1 totF:0 indx : 15 totE :1 totP:1 totF:0 indx : 16 totE :1 totP:1 totF:0 indx : 17 totE :1 totP:1 totF:0 indx : 18 totE :1 totP:1 totF:0 indx : 19 totE :1 totP:1 totF:0 Output at 2nd Execution: indx : 0 indx : 1 indx : 2 indx : 3 indx : 4 indx : 5 indx : 6 indx : 7 indx : 8 indx : 9 indx : 10 totE :2 totP:2 totF:0 indx : 11 totE :2 totP:2 totF:0 indx : 12 totE :2 totP:2 totF:0 indx : 13 totE :2 totP:2 totF:0 indx : 14 totE :2 totP:2 totF:0 indx : 15 totE :2 totP:2 totF:0 indx : 16 totE :2 totP:2 totF:0 indx : 17 totE :2 totP:2 totF:0 indx : 18 totE :2 totP:2 totF:0 indx : 19 totE :2 totP:2 totF:0 while i required same output on every execution.

    Read the article

  • Getting a ResultSet/RefCursor over a database link

    - by JonathanJ
    From the answers to http://stackoverflow.com/questions/1122175/calling-a-stored-proc-over-a-dblink it seems that it is not possible to call a stored procedure and get the ResultSet/RefCursor back if you are making the SP call across a remote DB link. We are also using Oracle 10g. We can successfully get single value results across the link, and can successfully call the SP and get the results locally but we get the same 'ORA-24338: statement handle not executed' error when reading the ResultSet from the remote DB. My question - is there any workaround to using the stored procedure? Is a shared view a better solution? Piped rows? Sample Stored Procedure: CREATE OR REPLACE PACKAGE BODY example_SP IS PROCEDURE get_terminals(p_CD_community IN community.CD_community%TYPE, p_cursor OUT SYS_REFCURSOR) IS BEGIN OPEN p_cursor FOR SELECT cd_terminal FROM terminal t, community c WHERE c.cd_community = p_CD_community AND t.id_community = c.id_community; END; END example_SP; / Sample Java code that works locally but not remotely: Connection conn = DBConnectionManagerFactory.getDBConnectionManager().getConnection(); CallableStatement cstmt = null; ResultSet rs = null; String community = "EXAMPLE"; try { cstmt = conn.prepareCall("{call example_SP.get_terminals@remote_address(?,?)}"); cstmt.setString(1, community); cstmt.registerOutParameter(2, OracleTypes.CURSOR); cstmt.execute(); rs = (ResultSet)cstmt.getObject(2); while (rs.next()) { LogUtil.getLog().logInfo("Terminal code=" + rs.getString( "cd_terminal" )); } }

    Read the article

  • pass ResultSet from servlet to JSP

    - by Dave
    Hi I am doing the following in my SampleServlet.java //Fill resultset from db ..... try { ArrayList Rows = new ArrayList(); while (resultSet.next()){ ArrayList row = new ArrayList(); for (int i = 1; i <= 7 ; i++){ row.add(resultSet.getString(i)); } Rows.add(row); } request.setAttribute("propertyList", Rows); RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher("/DisplayProperties.jsp"); requestDispatcher.forward(request,response); # and then in my jsp DisplayPropeties.jsp i have <% ArrayList rows = new ArrayList(); if (request.getSession().getAttribute("propertyList") != null) { rows = (ArrayList ) request.getSession().getAttribute("propertyList"); } %> but rows is allways null. Can anyone help with what I am doing wrong please.

    Read the article

  • How to get equivalent of ResultSetMetaData without ResultSet

    - by javanix
    Hey Guys - I need to resolve a bunch of column names to column indexes (so as to use some of the nice ResultSetMetaData methods). However, the only way that I know how to get a ResultSetMetaData object is by calling getMetaData() on some ResultSet. The problem I have with that is that grabbing a ResultSet takes up uneccesary resources in my mind - I don't really need to query the data in the table, I just want some information about the table. Does anyone know of any way to get a RSMD object without getting a ResultSet (from a potentially huge table) first? Thanks!

    Read the article

  • Java, Sychronize JTable and ResultSet

    - by rodion
    Hello, I have JTable, And AbstarctDataModel with fill(ResultSet rs) methods. How to correct synchronize cursor of JTable with ResultSet's cursor? Any links? Thanx a lat. P.S. Please, add AbstractTableModel tag -- Canton of Uri's citizen

    Read the article

  • Checking for a null int value from a Java ResultSet

    - by ian_scho_es
    In Java I'm trying to test for a null value, from a ResultSet, where the column is being cast to a primitive int type. int iVal; ResultSet rs = magicallyAppearingStmt.executeQuery(query); if (rs.next()) { if (rs.getObject("ID_PARENT") != null && !rs.wasNull()) { iVal = rs.getInt("ID_PARENT"); } } From the code fragment above, is there a better way to do this, and I assume that the second wasNull() test is redundant? Educate us, and Thanks

    Read the article

  • Problem with Sphinx resultset larger than 16 MB in MySQL

    - by gmemon
    Hello All, I am accessing a large indexed text dataset using sphinxse via MySQL. The size of resultset is on the order of gigabytes. However, I have noticed that MySQL stops the query with following error whenever the dataset is larger than 16MB: 1430 (HY000): There was a problem processing the query on the foreign data source. Data source error: bad searchd response length (length=16777523) length shows the length of resultset that offended MySQL. I have tried the same query with Sphinx's standalone search program. It works fine. I have tried all possible variables in both MySQL and Sphinx, but nothing is helping. I am using Sphinx 0.9.9 rc-2 and MySQL 5.1.46. Thanks

    Read the article

  • ResultSet and aggregation

    - by kachanov
    Ok, I admit my situation is special There is a data system that supports SQL-92 and JDBC interface However the SQL requets are pretty expensive, and in my application I need to retreive the same data multiple times and aggregate it ("group by") on different fields to show different dimensions of the same data. For example on one screen I have three tables that show the same set or records but aggregated by City (1st grid), by Population (2nd grid), by number of babies (3rd grid) This amounts to 3 SQL queries (which is very slow), UNLESS anyone of you can suggest any idea any library from apache commons or from google code, so that I can select all records into ResultSet and get 3 arrays of data group by different fields from this single ResultSet. Am I'm missing some obvious and unexpected solution to this problem?

    Read the article

  • How to obtain an scroll_insensitive resultSet from a callableStatement in Java JDBC?

    - by rafa colunga
    Hi, I have a stored procedure in an Oracle 10g database, in my java code, i call it with: CallableStatement cs = bdr.prepareCall("Begin ADMBAS01.pck_basilea_reportes.cargar_reporte(?,?,?,?,?); END;", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); cs.setInt(1, this.reportNumber); cs.registerOutParameter(2, OracleTypes.CURSOR); cs.registerOutParameter(3, OracleTypes.INTEGER); cs.registerOutParameter(4, OracleTypes.VARCHAR); cs.setDate(5, new java.sql.Date(this.fecha1.getTime())); cs.execute(); ResultSet rs = (ResultSet)cs.getObject(2); i do obtain an ResultSet with correct records in it, but when i try an "scroll_insensitive - only" operation, (like absolute(1) ). I keep getting an SQLException stating that it doesn't work on FORWARD only resultSet. So how can i obtain this ResultSet with scroll_insensitive capabilites? Thanks in Advance.

    Read the article

  • Problem with SQL, ResultSet in java

    - by aphex
    How can I iterate ResultSet ? I've tried with the following code, but i get the error java.sql.SQLException: Illegal operation on empty result set. while ( !rs.isLast()) { rs.next(); int id = rs.getInt("person_id"); SQL.getInstance().getSt().execute("INSERT ref_person_pub(person_id) VALUES(" + id + ")"); }

    Read the article

  • Reading ResultSet from multiple threads

    - by superdario
    Hello, In the database, I have a definition table that is read from the application once upon starting. This definition table rarely changes, so it makes sense to read it once and restart the application every time it changes. However, after the table is read (put into a ResultSet), it will be read by multiple handlers running in their own threads. How do you suggest to accomplish this? My idea was to populate a CachedRowSet, and then create a copy of this set (through the createCopy() method) for each handler every time a new request comes. Do you think this is wise? Does this offer a good performance? Thanks.

    Read the article

  • JDBC ResultSet.getString Before/After Start/End of ResultSet Exception

    - by Geowil
    I have done a lot of searching about this topic through Google but I have yet to find someone using getString() in the way that I am using it so I have not been able to fix this issue in the normal ways that are suggested. What I am trying to do is to obtain all of the information from the database and then use it to populate a table model within the program. I do so by obtaining the data with getString and place it into a String[] object: try { while (rSet.next()) { String row[] = {rSet.getString("DonorName"),rSet.getString("DonorCharity"),((String)rSet.getString("DonationAmount"))}; model.addRow(row); } } However I am always getting a dialog error message stating those error messages in the title: Exception: Before start of result set Exception: After end of result set The data is still added and everything works correctly but it is just annoying to have to dismiss those message windows. Does anyone have some suggestions?

    Read the article

  • SQL SERVER – Copy Column Headers from Resultset – SQL in Sixty Seconds #027 – Video

    - by pinaldave
    SQL Server Management Studio returns results in Grid View, Text View and to the file. When we copy results from Grid View to Excel there is a common complaint that the column  header displayed in resultset is not copied to the Excel. I often spend time in performance tuning databases and I run many DMV’s in SSMS to get a quick view of the server. In my case it is almost certain that I need all the time column headers when I copy my data to excel or any other place. SQL Server Management Studio have two different ways to do this. Method 1: Ad-hoc When result is rendered you can right click on the resultset and click on Copy Header. This will copy the headers along with the resultset. Additionally, you can use the shortcut key CTRL+SHIFT+C for coping column headers along with the resultset. Method 2: Option Setting at SSMS level This is SSMS level settings and I kept this option always selected as I often need the column headers when I select the resultset. Go Tools >> Options >> Query Results >> SQL Server >> Results to Grid >> Check the Box “Include column header when copying or saving the results.” Both of the methods are discussed in following SQL in Sixty Seconds Video. Here is the code used in the video. Related Tips in SQL in Sixty Seconds: Copy Column Headers in Query Analyzers in Result Set Getting Columns Headers without Result Data – SET FMTONLY ON If we like your idea we promise to share with you educational material. Reference: Pinal Dave (http://blog.sqlauthority.com) Filed under: Database, Pinal Dave, PostADay, SQL, SQL Authority, SQL in Sixty Seconds, SQL Query, SQL Scripts, SQL Server, SQL Server Management Studio, SQL Tips and Tricks, T SQL, Technology, Video

    Read the article

  • SQL SERVER – Copy Column Headers from Resultset – SQL in Sixty Seconds #026 – Video

    - by pinaldave
    SQL Server Management Studio returns results in Grid View, Text View and to the file. When we copy results from Grid View to Excel there is a common complaint that the column  header displayed in resultset is not copied to the Excel. I often spend time in performance tuning databases and I run many DMV’s in SSMS to get a quick view of the server. In my case it is almost certain that I need all the time column headers when I copy my data to excel or any other place. SQL Server Management Studio have two different ways to do this. Method 1: Ad-hoc When result is rendered you can right click on the resultset and click on Copy Header. This will copy the headers along with the resultset. Additionally, you can use the shortcut key CTRL+SHIFT+C for coping column headers along with the resultset. Method 2: Option Setting at SSMS level This is SSMS level settings and I kept this option always selected as I often need the column headers when I select the resultset. Go Tools >> Options >> Query Results >> SQL Server >> Results to Grid >> Check the Box “Include column header when copying or saving the results.” Both of the methods are discussed in following SQL in Sixty Seconds Video. Here is the code used in the video. Related Tips in SQL in Sixty Seconds: Copy Column Headers in Query Analyzers in Result Set Getting Columns Headers without Result Data – SET FMTONLY ON If we like your idea we promise to share with you educational material. Reference: Pinal Dave (http://blog.sqlauthority.com) Filed under: Database, Pinal Dave, PostADay, SQL, SQL Authority, SQL in Sixty Seconds, SQL Query, SQL Scripts, SQL Server, SQL Server Management Studio, SQL Tips and Tricks, T SQL, Technology, Video

    Read the article

  • assigning a specific record in a ResultSet to a variable

    - by kilhra
    Hi I want to retrieve a set of records from a database, do a rs.next() and then assign the result of this to a variable to pass to a method that will use this record, in the same way that I would without assigning it to a variable and passing it to a method is there any way to do this? I'm using JAVA (1.5)

    Read the article

  • SQL SERVER – Effect of Collation on Resultset – SQL in Sixty Seconds #026 – Video

    - by pinaldave
    Collation is a very important concept but often ignored. I have often seen developers either not understanding this or ignored it – this is plain wrong. In simple word we can say Collation is the language or interpreting done by SQL Server. Well, in today’s SQL in Sixty Seconds we are going to observe how collation affects the resultset. Today’s blog post is inspired from my earlier blog post SQL SERVER – Effect of Case Sensitive Collation on Resultset. I strongly encourage you to read this earlier blog post for sample code as well additional explanation related to the concept shared in today’s SQL in Sixty Seconds. Here is the code used in the video. USE TempDB GO -- Sample Data Building CREATE TABLE ColTable (Col1 VARCHAR(15) COLLATE Latin1_General_CI_AS, Col2 VARCHAR(14) COLLATE Latin1_General_CS_AS) ; INSERT ColTable(Col1, Col2) VALUES ('Apple','Apple'), ('apple','apple'), ('pineapple','pineapple'), ('Pineapple','Pineapple'); GO -- Retrieve Data SELECT * FROM ColTable GO -- Retrieve Data SELECT * FROM ColTable ORDER BY Col1 GO -- Retrieve Data SELECT * FROM ColTable ORDER BY Col2 GO -- Clean up DROP TABLE ColTable GO Related Tips in SQL in Sixty Seconds: SQL SERVER – Effect of Case Sensitive Collation on Resultset Example of Width Sensitive and Width Insensitive Collation Collation and Collation Sensitivity – Quiz – Puzzle – 6 of 31 Change Collation of Database Column – T-SQL Script Find Collation of Database and Table Column Using T-SQL Default Collation of SQL Server 2008 Cannot resolve collation conflict for equal to operation If we like your idea we promise to share with you educational material. Reference: Pinal Dave (http://blog.sqlauthority.com) Filed under: Database, Pinal Dave, PostADay, SQL, SQL Authority, SQL in Sixty Seconds, SQL Query, SQL Scripts, SQL Server, SQL Server Management Studio, SQL Tips and Tricks, T SQL, Technology, Video

    Read the article

  • How can I get a iterable resultset from the database using pdo, instead of a large array?

    - by Tchalvak
    I'm using PDO inside a database abstraction library function query. I'm using fetchAll(), which if you have a lot of results, can get memory intensive, so I want to provide an argument to toggle between a fetchAll associative array and a pdo result set that can be iterated over with foreach and requires less memory (somehow). I remember hearing about this, and I searched the PDO docs, but I couldn't find any useful way to do that. Does anyone know how to get an iterable resultset back from PDO instead of just a flat array? And am I right that using an iterable resultset will be easier on memory? I'm using Postgresql, if it matters in this case. . . . The current query function is as follows, just for clarity. /** * Running bound queries on the database. * * Use: query('select all from players limit :count', array('count'=>10)); * Or: query('select all from players limit :count', array('count'=>array(10, PDO::PARAM_INT))); **/ function query($sql_query, $bindings=array()){ DatabaseConnection::getInstance(); $statement = DatabaseConnection::$pdo->prepare($sql_query); foreach($bindings as $binding => $value){ if(is_array($value)){ $statement->bindParam($binding, $value[0], $value[1]); } else { $statement->bindValue($binding, $value); } } $statement->execute(); // TODO: Return an iterable resultset here, and allow switching between array and iterable resultset. return $statement->fetchAll(PDO::FETCH_ASSOC); }

    Read the article

  • SSIS - How do I use a resultset as input in a SQL task and get data types right?

    - by thursdaysgeek
    I am trying to merge records from an Oracle database table to my local SQL table. I have a variable for the package that is an Object, called OWell. I have a data flow task that gets the Oracle data as a SQL statment (select well_id, well_name from OWell order by Well_ID), and then a conversion task to convert well_id from a DT_STR of length 15 to a DT_WSTR; and convert well_name from a DT_STR of length 15 to DT_WSTR of length 50. That is then stored in the recordset OWell. The reason for the conversions is the table that I want to add records to has an identity field: SSIS shows well_id as a DT_WSTR of length 15, well_name a DT_WSTR of length 50. I then have a SQL task that connects to the local database and attempts to add records that are not there yet. I've tried various things: using the OWell as a result set and referring to it in my SQL statement. Currently, I have the ResultSet set to None, and the following SQL statment: Insert into WELL (WELL_ID, WELL_NAME) Select OWELL_ID, OWELL_NAME from OWell where OWELL_ID not in (select WELL.WELL_ID from WELL) For Parameter Mapping, I have Paramater 0, called OWell_ID, from my variable User::OWell. Parameter 1, called OWell_Name is from the same variable. Both are set to VARCHAR, although I've also tried NVARCHAR. I do not have a Result set. I am getting the following error: Error: 0xC002F210 at Insert records to FLEDG, Execute SQL Task: Executing the query "Insert into WELL (WELL_ID, WELL_NAME) Select OWELL..." failed with the following error: "An error occurred while extracting the result into a variable of type (DBTYPE_STR)". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly. I don't think it's a data type issue, but rather that I somehow am not using the resultset properly. How, exactly, am I supposed to refer to that recordset in my SQL task, so that I can use the two recordset fields and add records that are missing?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >