select « Operation « Java Database Q&A





1. JDBC insert into select between two databases(local and remote)    stackoverflow.com

There are two databases, the local one (damn MYOB data file, can only read locally via JDBC-ODBC connection), the other one is mysql which runs on another server. what is the best ...

2. How to "SELECT COUNT(*) FROM xz WHERE xz.a > value" with berkeleydb je    stackoverflow.com

What is the "SELECT COUNT(*) FROM xz WHERE xz.a > value" equivalent for berkeleydb je. http://www.oracle.com/technetwork/database/berkeleydb/performing.pdf lists most of the quieries I need. But this one is missing. Currently ...

3. How to use SELECT IN clause in JDBCTemplates?    stackoverflow.com

This is my first experience with JDBCTemplates and I ran into a case where I need to use a query that looks like this:

SELECT * FROM table WHERE field IN (?)
How ...

4. How to fire order by select query from Java?    stackoverflow.com

I am trying to query a table in SQL Server in ascending order from a JSP page but I am getting an error. Please help me?

5. SELECT query using executeUpdate() instead of executeQuery()    stackoverflow.com

for Ex:

class sample {

    public static void main(String a[]) {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con ...

6. problem caused by single quotes in select query    stackoverflow.com

public void getExp(String bool_expression,int groupId,int expLevel){
    List<String> list=new ArrayList<String>();
    List<String> nextExpressionList = new ArrayList<String>();
    try{
        ...

7. JDBC Problem wth select where query    stackoverflow.com

My Code:

con = jdbc.connect();
        System.out.println("status of con"+con);
String query = " select * from BmgCPUTotalUsage where CPUserID='"+CPUserID+"' and MessageTypeID='"+MessageTypeID+"'";
       ...

8. Java::Syntax error while running select query in Progress 9.1D Database    stackoverflow.com

I am connecting to Progress database 9.1D using JDBC progress Driver and running a select query.I have received a Syntax error(7587) for the same query in some of the scenaraio.Please find ...

9. How to select data of one table and insert in other table?    stackoverflow.com

I have a project in java where i want that certain data from one table (that is in Sql management studio) is selected and that is inserted in other table. So ...





10. Multiple "select" in one query    coderanch.com

Hi all Im connecting to a MS SQL database 7.0 using JDBC. I have to make the same query multiple times with the only change being a new "where" clause. Im trying to do this with a query that looks like this: queryString= "select sum(ITEM) as item from database where condition1; select sum(ITEM) as item2 from database where condition2;"; and Im ...

11. Batch update problem with nested select sql    coderanch.com

I have a problem with batch update. This is the code package provevarie; import java.sql.*; import javax.sql.*; public class ProvaDB { public static void main(String[] args) { try{ Class.forName("oracle.jdbc.driver.OracleDriver"); Connection conn = DriverManager.getConnection("jdbc racle:thin:XXXXXXXXXXXXXXXXXX"); conn.setAutoCommit(false); PreparedStatement pstm2 = conn.prepareStatement("INSERT INTO FATTURE VALUES (?,(SELECT NAME FROM ANAGRAFICA WHERE ID =?),?)"); pstm2.clearBatch(); for(int i = 1; i<4; i++){ pstm2.setInt(1,i); pstm2.setInt(2,i); pstm2.setInt(3,1000*i); pstm2.addBatch(); } ...

13. order in select query    coderanch.com

i just changed my query and using preparedstatement thereby able to restore the order i had asked for. hope the difference is not much when it comes to performance.anyways i would like to know if using a single select and "in", is it possible to restore the order given in the "in"... shankar.

14. SELECT Query Problem    coderanch.com

hello dears, i'm using Sql database. i have made JDBC/ODBC bridge. in tables my all fields are text. i need only SELECT Query for such i have written as this... String simple= "SELECT meaning FROM meaning "+" where word '"+s+"' "; Statement= connection.createStatement(); ResultSet=stmt.executeQuery(simple); i'm receiving this message when i'm running my Gui Application " Connection Error[Microsoft][ODBC SQL Server Driver][SQL Server] ...

15. Using select values for inserts in a batch    coderanch.com

Hi There, I want to insert into mutliple tables using batch update like this, Statement stmt= dbCon.createStatement(); stmt.addBatch("SELECT ID_SEQ.nextval as AID from dual"); stmt.addBatch("INSERT INTO AID_N VALUES (, "1"); stmt.addBatch("INSERT INTO AID_B VALUES (, "43"); stmt.addBatch("INSERT INTO AID_C VALUES (, "2"); How can I use the value AID selected in the first query, in the subsequent queries [inplace of ]. Thanks ...

16. select query    coderanch.com

I have a table called person, which has fields person number, name and age. I want a query which retrieves person details according to age group. i.e the program should be able to print people in the following age groups separately: <25 25 - 30 31 -35 >35 This means that the query should be able to select people who are ...





17. problem with a select query. Help!    coderanch.com

Hi, Imagine a simple database with a 'documentos' table. I have a main class: EjecutarSQL1.java, which calls to a BD class: BD.java, in order to make a query to the database. The problem is when I try to make a query like select count(*) from documentos or like select distinct name from documentos The output (the problem) is shown below. The ...

18. select cum update    coderanch.com

You can perform an update into using a select, but I think he's talking about modifying the data coming from the select statement artibitrarily. In that case you have to create a new statement to the database an execute an UPDATE sql command separately from your SELECT query. That's the cleaner/better way to do it anyway. For example, you may need ...

19. Insert with a select on the same table.    coderanch.com

Hi all I am trying to use a db connection using jdbc in order to insert a record into a table. The main issue is that I need to do a select on that same table first in order to find out what the last number was put in, as the record I am inserting is that number + 1. I ...

20. Some questions on "select for Update"    coderanch.com

Hi All, I have some questions on "select for Update" 1. If i do a "select for Update" on a table for a row (row identified by the key) & i donot do any update or commit or rollback, will the row stay locked for ever? 2. If i do "Select col1 from TAble1 for Update where..... ". In this case ...

21. Select Query with Comma Seperated Value    coderanch.com

Dear Ranchers, I'm doing a project in JSP and MySQL. In my page there is a text box and a submit Button named Search. When I enter in the textbox "Aravind,23,male".. it has to go into the database and has to search for "Aravind" whose age is "23" and sex is "male" and has to display the output When I enter ...

22. SELECT QUERY    coderanch.com

I think what David said is correct. By default the database creates an index on a key column (Primary Key). Its up to the programmer to create an index on a non-key column. The presence of keys in a table does not matter for the ordering of retrieval. Until and unless the ordering is mentioned in the SELECT statement it is ...

24. How to give search query if we select one than one value from combo box    coderanch.com

String[] strings = request.getParameterValues("

25. Why can I INSERT but not SELECT?    coderanch.com

In my webapp (an educational games database), I can add games to the database no problem, but I can't access the set of games once they're there. Using jdb with the following class, I found that st.executeQuery (GAMES_LIST_QUERY) is returning null. No exceptions are thrown, and the class seems to be connecting properly with the database. When I run the exact ...

26. SQL query problem: how tp select all duplication in the table?    coderanch.com

Hi all, I have a table with the following columns: 1. contact_id 2. fname 3. lname 4. email The email column must be unique (unfortunately it's not); therefore, I have to delete all duplication in the system. Question: how can I select all duplication in the table? I tried this...didn't work (I'm expecting only the emails that are duplicated) THANK YOU! ...

27. UPDATE with select statment    coderanch.com

eno name phone ----------- -------------------- ---------- 1 Quick and Dirty 1112223333 2 Starve Bucks 1112224444 3 JeffyGrease 1114443333 4 Stuffed Stuff 1112225555 RecommendedList eno eateryname phone ----------- -------------------- ---------- 4 Stuffed Stuff 7772225555 11 Pleasant Regrets 9992223333 12 Try Harder 8882224444 23 BBB's Choice 1114443333 1 Quick and Dirty 8882223333 " UPDATE Eateries SET Eateries.phone = (SELECT x.phone from RecommendedList x ...

28. Select query based on userinput    coderanch.com

Hi Folks... I am trying to make a select query based on a user input. Earlier I was having probelms making a select query and printing out the result in the stack trace,with the advice given here, I managed to solve that. I am now modifying that code to make a query based on user input, however it's not working, following ...

29. Select and update on the same table    coderanch.com

Hello I am facing a probelm that I can not find any "nice" solution. I have one select (that can read thousands of rows), in the loop where I read my resultset, I make some checks, some addition, and in some cases, I want to run an update. The update is on the same table as the selct. The update changes ...

30. problem with insert and select    coderanch.com

Hi i have 2 problem when i do the select query if i do SELECT * FROM Recipes, all is ok if i do SELECT Recipes,timeToEat, all is ok if i insert another column of my database, he took out an error second problem the insert doesnt run Datab /* * To change this template, choose Tools | Templates * and ...

31. how to make insert in to select query lock free    coderanch.com

Hi In my current project to fetch the report from database, we fire query by using union of multiple tables. As we are using nested query to fetch report, my sql creates a temp file to to do the manipulation of inner query which consists of union of multiple table. Due to this IO operation of the system gets high it ...

32. Weird update vs insert vs select from DB    coderanch.com

I'm having a strange thing happen with a db call in my servlet. Here is the code that is 'acting up'. String ids = request.getParameter("ID"); int id = Integer.parseInt(ids); try { ResultSet rs = stmt.executeQuery("SELECT * from APP.CUSTOMERINFO where CUSTOMERID =" + id); ids = request.getParameter("ID"); name = request.getParameter("Name"); address = request.getParameter("Shipping Address"); id = Integer.parseInt(ids); //check to see if the ...

34. query SELECT, WHERE    coderanch.com

35. Query solution for selecting record simultaneously from two DB tables, alternately    dbforums.com

I have a requirement where say I have File1 and File 2 have to be queried in such a way that when I select a record from File1, the next record should be from File 2, the third one from File1 and 4th from File2, in a single output query Ex: File1 Data Fld1 Fld2 001 India 002 China File2 Data ...

36. problem in select query    java-forums.org

37. SELECT FROM WHERE query    java-forums.org

You have declared your tablename as String , but are using as object ! this may be one of the reason your code fails! or if your table name is not dynamic enclose it with double quotes ! if your table.fieldname is of String type then the result of variablename must be in quotes , namely: "where table.fieldname= '"+variablename+"'"; :)

38. how to SELECT LAST_INSERT_ID() in java    java-forums.org

ResultSet rs = null; try { rs = stmt.getGeneratedKeys(); if (rs.next()) { autoIncKeyFromApi = rs.getInt(1); } else { throw new RuntimeException("PIB, can't find most recent insert we just entered"); } rs.close(); rs = null; } finally { if (rs != null) { try { rs.close(); } catch (SQLException ex) {} // ignore } try { stmt.close(); } catch (SQLException ex) {} ...

39. Problem executing SELECT query    java-forums.org

Hello. Create the following database with phpmyadmin CREATE TABLE course ( c_id VARCHAR(8) NOT NULL PRIMARY KEY, c_name VARCHAR(40) NOT NULL, c_ects SMALLINT NOT NULL ) ; insert into course values ('c1', 'Programming 1', 2) ; insert into course values ('c2', 'Programming 2', 2) ; insert into course values ('c3', 'Databases 1', 3) ; insert into course values ('c4', 'System analysis', ...

40. How to create a header from an sql select query in java    java-forums.org

Hi I have to create a header line from a select query and put it in an output file following the records from the query. For example , the query looks like this:- select name,room_no,cc1200,cc1201,cc1202,cc1203,cc1204,cc 1205 from student; The header should look like this name,room_no,00,01,02,03,04,05 I only need idea of what to use to get the header i want once i ...

41. how to select item from Jcombo box and insert it into database access    java-forums.org

kindly help me how to select and item from Jcombo box and insert it into a database access, i have try with this code below it show incompatible type and could not find symbol when i compile the code below : Java Code: import java.awt.*; import java.awt.event.*; import java.awt.Toolkit.*; import javax.swing.*; import javax.swing.JFrame; import javax.swing.border.*; import java.sql.*; import javax.swing.table.DefaultTableModel; import java.util.Vector; ...

43. Need help on inserting multiple selection values into database    forums.oracle.com

we are developing one small web application in that we have requirement like department is an combobox, services in multiple selection list box, suppose when i select IT as department & some services in multiple listbox on clicking map button selected services should be map with that department .Could u plz help me how i have to do..?