resultset

PHP: Checking for valid MySQL result resource

I have this code: $rows = array(); $res = mysql_query($someQuery); if(!mysql_errno()) while($row = mysql_fetch_assoc($res)) $rows[] = $row; some query is an arbitrary query that I write in to a form. The mysql_errno catches the case when I write a mysql query with errors in it. But, I just discovered that when I do a "Del...

Java ResultSet getString weirdness?!

This one has me stumped. I've got a java.sql.ResultSet and I'm pulling string values out of it like so: address.setAddressLine1(rs.getString("AddressLine1")); address.setAddressLine2(rs.getString("AddressLine2")); When I debug and inspect rs.getString("AddressLine1"), the debugger says I've got a 30 character string: "ATTN: ACCOUNTS ...

Easy way to fill up ResultSet with data

Dear All, I want to mock a ResultSet. Seriously. I'm refactoring one big complicated piece of code which is parsing data from ResultSet, and I want my code to behave identically. So, I need to write a unit test for the piece being refactored to be able to test this. After googling I came up with 2 ideas: Use EasyMock, write looooong ...

How to stub/mock JDBC ResultSet to work both with Java 5 and 6?

Hi, I'm testing some of my classes working with JDBC statements etc and now I got problem with JDBC ResultSet interface: The software should run both with Java 5 and Java 6 and hence the tests should also be run with both versions. Unfortunately Java 6 has introduced a bunch of new methods (which is still not a big deal) that return a ...

Behaviour of ResultSet after connection got corrupted.

Suppose I am making jdbc call and I had fetched data from db to resultset. But due to some network issue I lost my connection with db. (Connection, statement and resultset is not closed in DB). So can I still able to iterate resultset ? ...

Fastest way to write huge data in text file Java

I have to write huge data in text[csv] file. I used BufferedWriter to write the data and it took around 40 secs to write 174 mb of data. Is this the fastest speed java can offer? bufferedWriter = new BufferedWriter ( new FileWriter ( "fileName.csv" ) ); Note: These 40 secs include the time of iterating and fetching the records from re...

Batch multiple select statements when calling Oracle from ADO.NET

I want to batch multiple select statements to reduce round trips to the database. The code looks something like the pseudo code below. It works perfectly on SQL Server, but does not work on Oracle - Oracle complains about the sql syntax. I have had a look around and the only examples I can find of returning multiple result sets from Orac...

Resultset logic when selecting tables without a join?

Dumb question.. what logic does the database use to determine the result set if you do a select without a join such as: select * from table1, table2 ...

Django-sphinx result filtering using attributes?

Hi all, I was going through the django-sphinx documentation, and it looks like it allows you to filter search results using attributes, queryset = MyModel.search.query('query') results1 = queryset.order_by('@weight', '@id', 'my_attribute') results2 = queryset.filter(my_attribute=5) results3 = queryset.filter(my_other_attribute=[5, 3,4]...

copy resultSet without using cachedRowSet

I 'm trying to close the connection after executing a query. Before, I just create a CacheRowSetImpl instance and it will take care of release the resources for me. However, I am using hive database driver from hadoop project. It doesn't support CachedRowSetImpl.execute(). I'm wondering is there any other way that allow me to copy the re...

Possible memory leak due to not using StringBuffer?

Can the following code cause a memory leak? Would using a StringBuffer actually improve memory usage? A little background: A coworker has been pushing his theories on memory leaks, and this is code he has identified as being problem code (without doing any sort of profiling), which he claims can cause a memory leak. I disagree with this...

ResultSet and Select * Performance

I am refactoring some Spring JDBC code in which some of the costlier queries do "SELECT * FROM..." - and was about to start checking which columns were actually needed and just SELECT x , y FROM.. them. But reading through the ResultSet class is seemed that most data is lazily loaded. When you do a ResultSet.next() it moves the cursor ...

ResultSet.getBlob() Exception

The Code: ResultSet rs = null; try { conn = getConnection(); stmt = conn.prepareStatement(sql); rs = stmt.executeQuery(); while (rs.next()) { Blob blob = rs.getBlob("text"); byte[] blobbytes = blob.getBytes(1, (int) blob.length()); String text = new String(blobbytes); The result: java.sql.SQLExc...

How can I return only one resultset from a pivot query in sql server?

Hello, I have the following T-SQL Pivot query. SELECT AccountNumber, EventID, CreateDate, [ITEMBOOK] AS ITEMBOOK, [POSTER] AS POSTER FROM (SELECT ProductID, Quantity, EventID,AccountNumber,CreateDate FROM #tmpStartupItems) ps PIVOT ( SUM (Quantity) FOR ProductID IN ( [ITEMBOOK], [POSTER]) ) A...

JDBC Query excecution

I am facing an issue while executing queries.I use the same resultSet and statement for excecuting all the queries.Now I face an intermittent SQlException saying that connection is already closed.Now we have to either have separate resultSet for each query or have lock like structure.Can anyone tell which is better.I think introducing lo...

Flex 3 not returning all the rows from JDBC

I am requesting rows back from JDBC, and binding the values in objects through Flex/BlazeDS into an arraycollection. If I ask twice in sucession, using the same function for the data, the second one invariably returns all the values,and binds them properly into an arraycollection. the first one doesn't return any rows, but doesnlt thro...

JDBC: best way to update a table?

let's say that i get a resultset which was queryed using joins from an sql database. is it better to use an sql statement to update the tables or insert new tuples/rows? or should i use the resultSet.update() function? i just want to know the drawbacks associated with each as well as the preferred method of updating tables. ...

How to judge whether selected result is empty or not with jQuery?

$("#experiences tr") For the above one,how to judge if it's empty or not? I thought its boolean value should be false,but seems not. ...

MySQL resultset display by group

I have a table that looks like: Client_ID | Order_ID | 10 | 1 | 10 | 2 | 10 | 3 | 14 | 6 | 14 | 7 | 14 | 9 | Is there an elegant way in PHP of printing out this result set putting in evidence the client_id groups instead of making a loop that remembe...

How to select an empty result set?

I'm using a stored procedure in MySQL, with a CASE statement. In the ELSE clause of the CASE ( equivalent to default: ) I want to select and return an empty result set, thus avoiding to throw an SQL error by not handling the ELSE case, and instead return an empty result set as if a regular query would have returned no rows. So far I've...