sql 1 « Operation « Java Database Q&A





1. How do you query object collections in Java (Criteria/SQL-like)?    stackoverflow.com

Suppose you have a collection of a few hundred in-memory objects and you need to query this List to return objects matching some SQL or Criteria like query. For example, you ...

2. AS400 library/file (member) JDBC query    stackoverflow.com

Using JDBC (with jt400 driver / connection, naming=system) I'm running these SQL statements:

"CREATE ALIAS QTEMP/SOURCETEMP FOR " + library + "/" + file + " (" + member + ")"
"SELECT SRCDTA ...

3. create sql query in c++/java?    stackoverflow.com

which method do you prefer for creating dynamic sql queries? formating or streaming? Is it just preference or there any reason one is better than other?Or any special library you use to it. EDIT: Please ...

4. Querying Java Data Structures    stackoverflow.com

Is there any way to perform SQL Like Queries or Filtering on Java Data Structures? I want to filter objects in an ArrayList and a HashMap by fields of the objects contained ...

5. Where do you put your SQL Queries?    stackoverflow.com

We are using a mix of EJB 2.1 and JDBC to access our Database. I just had a co-worker mention the idea to put his SQL Queries into a .properties file. ...

6. Is there any library to represent SQL queries as objects in Java code?    stackoverflow.com

I was wondering if there is any library that can be used to represent SQL queries as objects in Java. In the code I have plenty of static variables of type java.lang.String ...

7. Best way to update in a db a list of mails    stackoverflow.com

I have the following db schema.

SQL> describe USERS;
 Name                       ...

8. How to query multiple SUMs of the same item using SQL in iReport    stackoverflow.com

  • I'm creating a JasperReport using iReport, and as such, I'm limited* to one SQL query.
  • I have a table 'statistics', with a 'name' (VARCHAR), 'count'(INTEGER), and 'datetime'(DATETIME) columns.
  • It is simple enough to ...

9. SQL queries running slowly or stuck after DBCC DBReindex or Alter Index    stackoverflow.com

All, SQL 2005 sp3, database is about 70gb in size. Once in a while when I reindex all of my indexes in all of my tables, the front end seems to freeze ...





10. Passively Monitoring SQL queries on Linux/Unix    stackoverflow.com

I am currently writing an application for monitoring SQL queries produced by a web application. I am interested in monitoring the SQL queries being sent by a given application passively. That ...

11. Eclipselink: Create objects from JOIN query    stackoverflow.com

I have a SQL query

SELECT * FROM Thing AS a JOIN Thing_Property AS b ON a.id=b.Thing_ID 
   JOIN Property AS c ON b.properties_ID = c.id 
   JOIN ...

12. Simple question on database query    stackoverflow.com

I have been asked in an interview to write a SQL query which fetches the first three records with highest value on some column from a table. I had written a ...

13. LogParser for Java    stackoverflow.com

I just read this post and i wonder if there is something like this for querying jboss log file.

14. Eclipselink and update trigger on multiple access to the database    stackoverflow.com

in my project I have a database which many clients connect to. Concurrent access and writing works well. The problem now is not to reload the data every second from the ...

15. How do you access the value of an SQL count () query in a Java program    stackoverflow.com

I want to get to the value I am finding using the COUNT command of SQL. Normally I enter the column name I want to access into the getInt() getString() method, ...

16. How to handle xpath in SQL query while programming in Java    stackoverflow.com

I am trying to execute the SQL statement from my java application Due website restriction on url I have replaced http=htp for this post.

SELECT DISTINCT(DID) 
  FROM (SELECT e_id DID,
 ...





17. The big last_insert_id() problem, again    stackoverflow.com

Note - this follows my question here: http://stackoverflow.com/questions/2983685/jdbc-does-the-connection-break-if-i-lose-reference-to-the-connection-object Now i have a created a class so i can deal with JDBC easily for the rest of my code -

public class Functions ...

18. sql query not executing    stackoverflow.com

Not able to execute a query ,i need to check if end date is greater than today in the following query Getting an error invalid query

select * from table1 where user ...

19. Problem with JDBC query with embedded comments    stackoverflow.com

I have a problem executing queries having comments via JDBC. Can you help us? This works:

select * from notf_worklist; SELECT * FROM NOTF_TASK_INSTANCE
The following query throws an error: "Error :com.microsoft.sqlserver.jdbc.SQLServerException: The index 1 ...

20. XMLType - SQL state [99999]; error code [31011]; could not update:    stackoverflow.com

http://stackoverflow.com/questions/3064330/how-to-map-xmltype-with-jpa-hibernate I have done XMLType mappings with Hibernate @Type with the help of above URL. It works fine when I persist with the data type HibernateXmlType. It has results however, it throws ...

21. How to read sql query from xml using java    stackoverflow.com

How to read sql query from xml using java

22. Nested Callback Handlers?    stackoverflow.com

I am getting a set of data from the database where the query produces a repetition of data with a different "Special" value. For example the user "A" can be repeated ...

23. How to search and insert a value using java code?    stackoverflow.com

  String link = "http://hosted.ap.org";
I want to find whether the given url is already existing in the SQL DB under the table name "urls". If the given url is not ...

24. How to find that a SQL query executed has returned nothing?    stackoverflow.com

import java.net.URL;
import java.net.URLConnection;
import java.sql.*;
public class searchlink{
public static void main(String args[]) throws Exception {
    //String link="http://hosted.ap.org";
    Connection con=null;
    Statement stmt=null;
    ...

25. JDBC general query execution    stackoverflow.com

Is there a way, in JDBC, to execute a generic query ? I mean run something like execute(String strSql) where strSql could be a SELECT, an INSERT, an UPDATE,a CREATE,... or whatever. If ...

26. Multiple insert in a loop in jdbc    stackoverflow.com

while (tokens.hasMoreTokens()) 
{
    keyword = tokens.nextToken();
    System.out.println("File= "+fileid+" Keyword=" + keyword);
    stmt.executeUpdate(
        "INSERT into TEXTVALUEINVERTEDINDEX ...

27. how do I get update notification from server to client?    stackoverflow.com

Hi I am doing a task using socket programming,in this I have database on server side and whenver any employee update any table ,server should notify all employee by triggring pop ...

28. extracting data from a sql query    stackoverflow.com

IF I have a query like: Then while doing it, should I write each entry from the table to get the output. like Now How I get all the entries of my table ...

29. In general, where to place SQL queries in an application?    stackoverflow.com

what is the best place to place SQL queries in an application? The queries might be big and requires formatting. Appending the query using StringBuilder looks very cluttered. Storing them in files and reading ...

30. How to unit test an SQL query?    stackoverflow.com

I have a class DBHandler which takes a query, runs it through the SQL server, checks for errors and returns the result. How can I unit test this class? Edit: I'll try ...

31. Using one query in another in JDBC programming    stackoverflow.com

I understand how to do this on paper in SQL, but am having trouble implementing this in Java (this is the first time I am actually programming JDBC stuff) For example, say ...

32. Design Problem - Generating SQL Queries for business calculations    stackoverflow.com

We have an application where the user is allowed to enter expressions for performing calculations on the fields of a database table. The calculations allows various types of functions (math, logic, ...

33. Transferring an SQL query from the workbench to a .java class    stackoverflow.com

I'm trying to transfer an SQL query into java from my workbench. I wrote this query in the mySQL workbench and it executed fine with the results I wanted. SELECT committee_member.member_CAN#, member.first_name, member.last_name, ...

34. Rewrite this function as DB query?    stackoverflow.com

I'm cleaning up my code, should i change the following function to a MySQL query? If so what would be a nice MySQL function to achieve this functionality?

public ArrayList getNewTitles(ArrayList candidateTitles, ...

35. Jasper Reports: How to pass multiple SQL queries from a Java Program    stackoverflow.com

I have constructed a Jasper Report using iReport tool, where in I have registered two data sets, one to polulate the data in a table, and other to display a chart. ...

36. java web application - model design for displaying list with a sql join    stackoverflow.com

I am authoring a javabean and would like to know if it should include properties to set values obtained from a sql join? Say I have database tables for Products and Orders. ...

37. Error in JDBC query    stackoverflow.com

sql  = "select milk_rate from special_milk_rate 
        where code_producer_id=? and effective_from <= ? 
        and effective_till ...

38. Where should logic go for deciding which SQL query to execute    stackoverflow.com

I have a DAO with a method CommitmentListDAO.getListByOwnerBadge that returns an arraylist of commitment items against a supervisor badge (database field OWNED_BY)

    String SQL_VIEW_LIST_BY_SUPERVISOR = SELECT_QUERY + 
 ...

39. JDBC- SQL spatio-temporal query    stackoverflow.com

trajectory table

       OBJID      PLACE       
        ...

40. Using % in SQL query    stackoverflow.com

SELECT MAX(sm_version) AS version_latest, 
       user_type       AS role_performed 
FROM   usage_database 
WHERE  user_id LIKE ( '"+%eid_upper+"' ) ...

41. SQL query works fine in TOAD , but not when placed in java code    stackoverflow.com

The following sql query executes fine when ran in TOAD editor and shows results,but does not fail or show results when placed in java code.

CREATE TABLE CDRRD.C31820_ADHOCM ...

42. assigning value from a query?    stackoverflow.com

I am writing a java program which will create a database LocalStations where it needs a value maxStationid int maxStationId; I want to assign maxStationId with the total number of cells in the ...

43. Is SQL injection possible with this query?    stackoverflow.com

UPDATE `company` SET `itnumber` = '595959' WHERE (id = 932) 
So the value of itnumber is coming from user input for that company. I want to make sure I am able ...

44. Designing Java Object for SQL Query    stackoverflow.com

Are there any good utils/frameworks which could generate Java Object for SQL Query?

45. Update query does not work    stackoverflow.com

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connect =DriverManager.getConnection("jdbc:oracle:thin:@172.17.0.14:1521:develop","sis","psgh");

String qry=("update sample set one=2 where two=3");
PreparedStatement ps = null;
ps=connect.prepareStatement(qry);

int i=ps.executeUpdate();
if(i==1)
    out.println("success");
else
    out.println("failed");
The above code is not working The table is
create table (one ...

46. Error with simple Parameterized Query - Java/ SQL    stackoverflow.com

Following on from one of my previous questions to do with method design I was advised to implemented my SQL queries as a parameterized query as opposed to a simple ...

47. I want to search all the persons in the religion by giving religion name in the textbox required query    stackoverflow.com

Possible Duplicate: I want to search all the person in city by giving the city name
How do I search all the persons in the religion by giving ...

48. java open source generate sql query from xml    stackoverflow.com

In java, do we have an open source to generate sql from an xml file? For example, the simplest case is :

<query>
  <select>id</select>
  <from>student</from>
   <equal><column>name</column><val>john</val></equal>
   ...

49. JDBC Insertion Issue    stackoverflow.com

So I have a doPost method in an order checkout servlet which checks the value of a 'commit' parameter and is supposed to insert an order record into the database if ...

50. How to use CreateNativeQuery to query single value from SQL database value?    stackoverflow.com

using a CRUD and want o access a certain value in the databse. what I tried is:

Query query = em.createNativeQuery("select o from Table o where o.IDfield= '938'"); 
Table o = (Table)query.getSingleResult();
but ...

51. Converting SQL update based application to java rule based application    stackoverflow.com

I have an data centric & data sensitive application, which is written using java, but almost all the business logic is maintained in a .sql files. These sql files are executed 1 ...

52. Joins are for lazy people?    stackoverflow.com

I recently had a discussion with another developer who claimed to me that JOINs (SQL) are useless. This is technically true but he added that using joins is less efficient than ...

53. how to isolate SQL queries from code    stackoverflow.com

We are developing an application which uses JDBC API. We deal with lot of queries for various use cases. Any idea on how to isolate these SQL queries out of ...

54. Splitting Long running SQL query into multiple smaller queries    stackoverflow.com

I am using SQL Server 2008 and Java 6 / Spring jdbc. We have a table with records count ~60mn. We need to load this entire table into memory, but firing select * ...

55. Open source sql query tool in java    stackoverflow.com

I need to know of any open-source sql query/builder tool in java. The thing is, it should be able to relate & join multiple tables in my database & give me ...

56. Subset returned by queryForList is incorrect,but executed in SQL Developer it's OK    stackoverflow.com

Subset returned in DAO class:

List<Map<String, Object>> agreements = getJdbcTemplate().queryForList(sqlForDataQuery.toString(), paramsForList.toArray());
It expected to be sorted,but in debug mode application returns incorrect subset - it's not sorted.
From other hand,if to execute sqlForDataQuery with ...

57. Multiple dropdown boxes all with SQL queries    stackoverflow.com

I am trying to write a program that queries a mysql database. The first dropdown box is popluated with an SQL query which returns a list of tables within the database. The user ...

58. how to retrieve the queries used in a store procedure through jdbc    stackoverflow.com

I have been calling a stored procedure through jdbc and i have a requirement that the queries used in that stored procedure should be displayed on console. can you suggest a code ...

59. java.lang.NullPointerException in search query    stackoverflow.com

import java.sql.*;
import java.io.*;

public class User {
    String s1;
    int age;
    String s2;
    String s3;

    /**
  ...

60. Seperate thread for SQL DB Queries    stackoverflow.com

I am writing an application which will have to regularly poll an SQL Databse to get the latest entries. These entries will be translated into Java Objects and passed to the ...

61. Loading the data and process them programmatically is faster than SQL queries?    stackoverflow.com

Is it true that loading the data and process them programmatically is faster than SQL queries ? I am supposed to optimized the legacy applications which are running slow because of ...

62. Java - Avoiding long sql query in code    stackoverflow.com

In my Java code , I have something like this :

ResultSet rs = statement.executeQuery(
                  ...

63. Using QueryRunner to insert ArrayList    stackoverflow.com

I want to use QueryRunner to perform an insert of an ArrayList. The only information I am finding online is for inserting one Object[]. Something along the lines of:

qr.update("insert ...

64. SQL Query passing values from Java    stackoverflow.com

I would like to know if when I place a sql query using java , does it retain the new lines? for instance if i have

"IF EXISTS (SELECT * FROM ...

65. How to pass List in sql query    stackoverflow.com

I have of values (1, 2, 3, for example), and I want to pass that list to a SQL query:

"select name from tbl where id in" + list 
How might I ...

66. Error in the native query    stackoverflow.com

Im new to sql and im facing a problem with the below native query

 public void saveOfflineBatchDetails(BigInteger user_id) {

    em.createNativeQuery("INSERT INTO rst_offline_transaction_batch (created_date , user_id)" +
  ...

67. check out my sql query filter method,is this safe?    stackoverflow.com

String searchSQLFilter(String keyword){         
    for(String filter:new String[]{"|","&","*","%",";","-","+",",","<",">"}){
        keyword=keyword.replaceAll("\\Q"+filter+"\\E", ""); 
    ...

68. Best way to store small, alternating, public data that updates every couple of hours?    stackoverflow.com

The essence of my problem is that there are too many solutions, and I would like to find which one wins out in pros and cons before I build an infrastructure ...

69. Parse SQL query in Java with UTF-8 support    stackoverflow.com

What (tool, library, way) can you recommend for parsing SQL query in Java?
I need to change column names in output, so for example:
I want to change query from:

SELECT a ...

70. Firebird + JDBC: Getting the generated key from an insert    stackoverflow.com

It looks like Firebird does NOT support getGeneratedKeys() after you perform an insert with an auto_increment column. So I would like to understand how I can get my hands on the ...

71. Insert in Microsoft SQL using JDBC    stackoverflow.com

I have some data coming from a machine in the following format: A (some value) B (some value) C (some value) and so on. I have a database in the Microsoft SQL server 2008 ...

72. sql update statment does not execute properly    stackoverflow.com

I'm having problem with an update query. following is the function I'm calling:

public static void update(ArrayList<String> arr, int id)
{   
    Connection conn = null;
   ...

73. How can I update an xml file periodically?    stackoverflow.com

Hy, I have to make a query on a Facebook table witch will return xml information about number of likes and so on.I have to keep those info in database or in ...

74. REFACTOR: Clean dao code for a query with multiple optional params    stackoverflow.com

Is there a possiblity to clean up such a dao method? I don't like the 2 if's for each param, but there isn't something like "query.setSql()" so i could update the sql ...

75. insert values into SQL database using JDBC    stackoverflow.com

hi am trying to insert values into SQL database using jdbc. Current code able to connect and query sql DB. am using executeupdate to insert the values .this code is ...

76. Remove duplicate values during insertion    stackoverflow.com

i am trying to insert values into database from excel spreadsheet .am doing it using JDBC.connected both excel and sql database. i have these columns dc:Title,dc:dcid,dc:subject,dc:description,dc:publisher,dc:language in SQL database. in which ...

77. How would I list the data from an SQL query in Java?    stackoverflow.com

Here is my code, it does get data and paste it in the Text Area as I want it to do, I was just wondering if I could change it so ...

78. sql query- using AND    stackoverflow.com

The following query does not return any result

SELECT user_id FROM test WHERE  poll_id = 2 AND (question_id = 2 AND answer_id = 5) AND (question_id = 3 AND answer_id ...

79. JDBC How to Insert into.. Value('StringArray[0]', 'StringArray[1]','StringArray[2]','StringArray[3]'....) into databse    stackoverflow.com

I tried to read a file and write the data into database: The file is read to store into the string array, such like

 String[] result = new String[numberofToken];
then i ...

80. dynamically generated parent key into another query    stackoverflow.com

I have to take a value from one table which I have just added using seq.nextval(say Query 1) into another table for entering further information into another table through Query 2.I ...

81. Write queries in an XML file and bind with values using java    stackoverflow.com

How do I write queries in an XML file and bind with values using Java? GetPerson.java:

String name='java';
String query=getQuery(name); // from XML
// query must be like this:
//     ...

82. sql query    bytes.com

83. Running SQL queries using a JDBC    forums.netbeans.org

Ok, so I have been searching far and wide to an answer to this question and I am most likely not wording it correctly in google but I hope that I ...

84. SQL queries executed twice in 'Execute command' window    forums.netbeans.org

Hi all. It seems to me that queries in the 'Execute command' window (Services -> Databases -> Execute command...) are executed twice. A small test case follows: 1) Open a MySQL connection 2) open an 'Execute command' window and create a table and a stored function to emulate a sequence id generator: DROP TABLE IF EXISTS SEQUENCE_GENERATOR; CREATE TABLE IF NOT ...

85. Netbeans & SQL queries    forums.netbeans.org

86. Correctly using sql query call    jmeter.512774.n5.nabble.com

> I want to call a sql query and then have the data populate a soap request > > I would expect I could do something like > > THREAD GROUP > JDBC_REQUEST (select col1, col2 from table) > FOREACH CONTROLLER > ---SOAP REQUEST USING ${col1} and ${col2) > > > But no luck. > ...

87. JDBC Request - SQL Query type    jmeter.512774.n5.nabble.com

88. Problem with jdbc SQL Query    jmeter.512774.n5.nabble.com

Hi, I'm having trouble getting the resuklt recordset when I execute a SQL procedure, in a JDBC request. When I select in the Query type; "Select statement", the execution of the procedure (informix) returns a recordset with all fields field with the value for the last column of the recordset. Any ideas? Regards, ...

89. response data from sql queries in JDBC request    jmeter.512774.n5.nabble.com

> Hi Sebb, > > > Are you saying I should have 1 SQL query per JDBC request? > > Is it not poosible to have mutliple queries within one JDBC request? > > Thanks > > > Aidy > > > On 15/03/2009, sebb <[hidden email]> wrote: > > Why not just use several ...

90. SQL query????    coderanch.com

I am not as familiar with PL/SQL, but in T-SQL you have a TOP command. So you can say something like this: SELECT TOP 1 field FROM table ORDER BY field I'll try to find out if this is supported in PL/SQL or if there is some equivalent. Bill [This message has been edited by bill bozeman (edited April 20, 2001).] ...

91. Help with sql update command ->    coderanch.com

Hi there! I am trying to update a table in my access database, the code in my bean for doing this is: // Create the statement object --> Statement statement = connection.createStatement(); // Define and execute the sql update --> String update = "UPDATE user SET FNAME="+fName+",LNAME="+lName+",USERID="+userId+",PASSWORD="+password+" WHERE FNAME="+user; statement.executeUpdate(update); I get no errors so I thought everything was working just ...

92. urgent sql query    coderanch.com

93. SQL Query    coderanch.com

Hi ! I have 2 tables with the following structure: Table 1: A | B | C --------- rec.1 a1| b1| c1 rec.2 a1| b2| c1 and Table 2: B | C | D ----------- b1| c1| d1 b2| c2| d2 Could someone help me with a query which finds all records from Table 2 with the pair (b,c) which are ...

94. Time Taken by any sql query    coderanch.com

Hi ranchers, I need little assistance from you guys.I need to know is their anyway of calculating time taken by any sql query. What i want is that when user search for anything from my database i want to show a progress bar showing how much time left. Its little urgent.. Thanx for reading...

95. sql query    coderanch.com

97. How to construct an SQL query to return data from a 1-to-MANY relationship?    coderanch.com

I cant believe I'm asking this question considering I thought I knew SQL, only I have not used it recently, hehehe, ok, here's the deal: Lets say we have a CAR and a PART table, and the relationship between them is 1-to-many, in that a CAR contains many PARTs. The table CAR has the following simple attributes: CAR.number CAR.name CAR.description CAR.weight ...

98. SQL Query for Airline Reservation    coderanch.com

In Airline Reservation System, I want to determine the various connectivities between two different cities. There might be N combinations for the above query. i.e A-->B-->C-->D A-->E-->F-->D A-->E->D How will I solve this problem in MS-SQL, do we have the facility for recursion with tables. And one more doubt : What is exactly a leg?

99. help with inserting vales to a sql database    coderanch.com

Hello everyone I am having this problem with how to fill my values in my sql statement, if you look below you will notice i have set up the values to be the length of the arr (arrayList). could someone please let me now how i should put there values in. thanks for yr time ben try { String data = ...

100. Whats the Importance Of Sequence Of Conditions In an Sql Query    coderanch.com

Hi, It does matters...in a sequence of conditions in a sql each next call has to wait for the previous one so the performance of the query goes down and it becomes worse if u are using a simple statement for the query...if u want to know more just tell me what exactly u want to know... Regards... Neeraj