sql 3 « Operation « Java Database Q&A





1. Validating the SQL Query    coderanch.com

I agree with the responses above there are many ways a SQL statement can be invalid as well as giving a users access to execute raw SQL statements can be destructive to your database. if you must go this route. I would suggest you provide a series of drop down lists where you have more control on what the users can ...

2. SQL Query    coderanch.com

3. Problem with sql query    coderanch.com

Hi there, I had to take care of someone else code.. He made a stored procedure using Oracle 10g but there is a little problem. In this proc, there are two UPDATE on the same row . The first let the field be NULL to make sure that if there is no update, fields are reset. The second one update the ...

4. how to put Nested conditions in sql query    coderanch.com

I find some solution for the above problem but it is taking too much of time to extract data...please genralize and ease it... SELECT distinct Crit.msgSeqId, Crit.messageMaster.messageId,CaseDt.caseCreatedDate,Rslt.caseId, PayInstExt.instructionIdentification, Usr.firstName, CaseDt.caseCreator, CAI.caseStatus, Rslt.sender, MsgM.messageName, Rslt.msgDateTime, Rslt.actionReq, Rslt.msgStatus, Rslt.direction,Rslt.messageReference,Rslt.msgSeqId,Crit.msgStatus, case Rslt.direction when ('incoming')then (case Crit.messageMaster.messageId when '5' then 'true' when '12' then 'true' when '11' then 'true' when '14' then 'true' when '1' ...

5. Optimizing an SQL Query    coderanch.com

Hi , Assume that i am having a SQL Query , for example "Select * from emp where Deptno=20" Now please tell me , how can i optimize or fine tune this SQL Query , so that i can assume taht this is the best way to write an SQL Query . Thanks . please saher your views on this . ...

6. Reading and loading sql queries from properties file    coderanch.com

Hi all, I am working on a web application project whose access to data is done by using the DAO pattern. Here I need to load the queries from a properties file placed inside WEB-INF. Following is the code i used: PreparedStatementCreatorBean package net.util; import java.io.InputStream; import java.io.IOException; import java.util.Properties; import java.sql.Connection; import java.sql.Date; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Time; import ...

7. Parse SQL Query using java    coderanch.com

Hi user create some sql query. In query contains selected coloumns,and aggregate functions etc. I need to separate selected coloumn using java. For Ex: SELECT EMP_NAME,EMP_NO,EMP_ADDRESS,EMP_RELION,EMP_PINCODE,EMP_MOBILE, DECODE(EMP_NAME,'TEST', EMP_NAME,EMP_NAME) from EMP; I am trying to parse query using StringTokenizer using "," separator but not parse in properly How to do this. Can you give me a solution for this.

8. First Post - Multiple SQL Queries with JDBC Error?    coderanch.com

Hi All, First post, so please go easy I am producing a small website for educational purposes, and very new to JSP and the JDBC. I have been stuck all day, on a small piece of code (which have fundamental issues), and hopefully someone can help . As its the holiday season, i have emailed my tutor for some help but ...





10. sql query regarding order    coderanch.com

11. sql query issue    coderanch.com

13. SQL Query    coderanch.com

the main requirent is see: select d.dmedocno from document d JOIN custprop c ON d.documentid=c.documentid where (c.strdata is not null or c.datedata is not null or c.numdata is not null or c.booldata is not null or c.blobdata is not null) group by d.dmedocno having count(c.propertyname)=4 This above returns returns about 63000 rows each containing one document number like eg 13434 22321 ...

15. pattern matching in sql query    coderanch.com





17. SQL Update not happening    coderanch.com

i'm writing a jsp file that takes theatre, movie name,cast,director,language,opendate,closedate(all are stirings). I'm getting their values in the servlet and passing them to the class to do the update.. No exceptions found.. but still the update is not happening... here is the code below JSP file <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> ...

18. using a session value on sql query    coderanch.com

ok...so this is my query... SELECT "JUN_F1"."Renta" FROM public."JUN_F1" WHERE "JUN_F1"."Telefono" = '9717029902'; JUN_F1 is the name of my table but that name, however this name is formed by JUN (variable) and _F1 (text)...I cant write my query to store in a string variable to do what i need to do, the problem is the quotes..basically my query will look like ...

19. How can i pass valid email address as a prarameter value in sql query    coderanch.com

first of all thanks for repling my post, actually my requirment is setting email value dynamically. first i am trying to do in static manar that is i am fixing the email value as String se="sudheer@ca.com"; This is "se" value may sent to the query as a paramater value. In database also Email is stored like this only(sudheer@ca.com) query is : ...

20. Sql query isssue    coderanch.com

21. SQL Query Issues: Avoiding cartesian product and right JOIN syntax    coderanch.com

Hi, You have to add your join conditions. If you say that ID and ROWREF are the link, then you have to tell your SQL query that ID has to be equal to ROWREF. In your query "SELECT ID, CREATED, ROWREF, AHT, SDATA FROM DATOS, TICKET" , you can add join conditions in the WHERE clause of your SQL statement.

22. Cannot perform SQL UPDATE null    coderanch.com

Hi, My Jtable retrives a database table . Some of the cells in the table are varchar, they are empty and initiallized to " ". Some other are integer and initialized to -1 and some others are date cannot be initialized to any date value so they are null. When I try to update the database using the update set.... method, ...

23. SQL Query using WHERE clause.    coderanch.com

Hello, I am trying to implement this method, but the where clause in the sql seems to be not working. My database has the fields : ID, lastName, firstName, mi, address, city, state, telephone, email with 2 records. The code attempts to display a specific record whose id is entered by the user in a JApplet's Textfield and then, the other ...

24. Automatic re-run of queries in java.sql.*    dbforums.com

As far as I have seen there is no way to rerun a previous transaction. You can just catch it and try again Usually if you are doing this it is a symptom of other problems that need to be looked at though. My uninformed and inexperienced guess is that the problem will grow worse and more users/threads are using the ...

25. Making SQL Query by Using All Possible Combinations of Given Words    dbforums.com

Hi, I have come across a challenge (for me at least) that I need to make an SQL Query by using all possible combinations of typed words to find the right records. For example, the DB field contains the following: HILTON WASHINGTON, 1919 CONN AVE., NW, DC., 20009 The user might search for: hilton conn ave hilton NW dc hilton washington ...

26. SQL Query    dbforums.com

Hi, I have a database table contains a field that has date like 1,3/3,0/30,0/2,1/4,2 , and I am trying to make a sql query to query out this record if two numbers seperated by comma, left side is equal to 1 and right site is greater than 0. Is it possible? if so, how can I do it? Thank you very ...

27. Sql Query    java-forums.org

Hi, I'm working on a client management system. in my database i have a customer table a product table so if the customer clicks details he gets the customer table and if he clicks on last bought products for example he gets the product table What is a better design to have a long table containing both the customer and product ...

28. insert java code to SQL    java-forums.org

it is string! and this a class of the software which connevts it to the database Java Code: package mynature; import com.mysql.jdbc.Connection; import com.mysql.jdbc.Statement; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Date; import java.util.logging.Level; import java.util.logging.Logger; /** * * @author Rashid */ public class DataBase { private Connection conn = null; private String userName = "root"; private String password ...

30. SQL query won't stick in the database :confused:    java-forums.org

Hi! I'm using Netbeans 6.8 and my MySQL connector is working fine. And when I do create my tables and consequently read them it seems to be working like a charm, however, when I try to read them again they're not there? I check manually in the MySQL command prompt and the tables are there, but they're empty ? :confused: So ...

31. SQL Update with ? as values    java-forums.org

Hi, I am trying to get the password collumn in my database to update with a new password from which the user will enter into a Java GUI. The Java side is working fine, however my SQL is complaining saying that 'ERROR: null value in column "password" violates not-null constraint'. Even though I am actually specifying a value. Here is the ...

32. need sql query    java-forums.org

hi , i need sql query which will fetch both upper and lower case letter should be arranged in ascending order.For example i have records in DB like Arabic Bus arabia car Court employee Engine i need to sort those values and fetch and display in UI page. Arabic arabia Court car Engine employee like this. i have used Select * ...

33. HELP: SQL Query Validator    java-forums.org

I am using execute method of preparedStatement. before executing i set the autoCommit property to false, and at last i roll back also. in case of exception, i show Invalid Query, otherwise the Query Syntax is correct. I am displaying the exception message in case of failure. The messge is good from a prograamer point of view, but end user can't ...

35. SQL Update function    java-forums.org

can't see what i'm doing wrong... it'll prob be another stupid typo but just can't seem to find it i'll explain what i'm hoping to achieve. :p so i'm making a little project(kind of rpg game) and i want to save wich language the user wants to use. so i made a table in MSAccess database and with those two values ...

36. Edit SQL QUERY IN DESIGN VIEW    java-forums.org

37. error in sql query    java-forums.org

38. pls somebody help me ; need to understand SQL queries from DAOImpl class    java-forums.org

pls somebody help me ; need to understand SQL queries from DAOImpl class Hi I just have joined a company as a Junior software engineer. I was asked to analyze an App named CRM Admin Console and find out the tables and their relation. This admin console authenticates user. Now I need to build a web application named Promo ...

39. update sql database    forums.oracle.com

hi, am using struts to build a small application ...say i have 10 fileds in a jsp page and 10 corresponding columns in sql db table. if 5 among 10 fields in jsp have been modified leaving 5 other fileds unchanged, then could you please help me with code on how to update the only 5 corresponding fileds in database without ...

40. SQL MAX QUERY / SQL COUNT QUERY    forums.oracle.com

41. query about sql interface with html    forums.oracle.com

42. PostGre SQL Query In JavaScript    forums.oracle.com

43. get sql query type    forums.oracle.com

Hack alert! No good. What about calls to stored procedures which might return a resultset or not depending on their implementation? And if you accommodate them in your parsing code there, you're likely going to miss something else as well, and so forth, until eventually you've basically reinvented the SQL parsing wheel.

44. sql insert in Java vs. sql dts package    forums.oracle.com

My opinion is for 3000 records, it would be a small enough speed difference that you should use a cohesive approach and just write it in java instead of forking a batch job from java. When you run a batch, you are no longer platform independent and have to worry about another proecess to watch and more output to parse. My ...

45. SQL Query building library?    forums.oracle.com

46. SQL Insert    forums.oracle.com

I am trying to use the following insert statement to add the contents of the variable imagePath and the word landscape into the path field and keyword1 filed respectively stmt.executeUpdate("INSERT INTO Images ( path,keyword1) VALUES (imagePath, landscape)");. however it returns an SQLException stating too few parameters. Edited by: shaungoater on Mar 20, 2008 5:21 AM

47. Parameterised query error for SQL 2005    forums.oracle.com

48. SQL Query Question...    forums.oracle.com

I am using SQL to query my flight system database, One of the tables has a fair few columns and i wondered if there is a shorthand way of selecting all columns except 1... so something like: "select * from table except for plane" where plane is a column in the table... as opposed to listing all the columns you want. ...

49. Mixing the sql query application with SimpleTableDemo    forums.oracle.com

import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; public class SimpleTableDemo extends JPanel { private boolean DEBUG = false; public SimpleTableDemo() { super(new GridLayout(1,0)); String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"}; Object[][] data = { {"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)}, {"Alison", "Huml", "Rowing", new Integer(3), new ...

50. Inserting java attributes into SQL    forums.oracle.com

51. Using multiple sql query    forums.oracle.com

Im writing a jsp that pulls data from the database and loads it into dropdown-list looks like this:

52. How to write a SQL query in Java    forums.oracle.com

53. ensuring an sql query execution is successful    forums.oracle.com

Your method effectively just calls executeUpdate and does no additional work. Why do you do that? executeUpdate() already has a pretty clear contract: It returns the number of effected rows. Some callers might want to check that and treat it as an error if it returns an unexpected value (0 or > 1 usually). It throws an Exception if something is ...

55. saving sql query to database    forums.oracle.com

57. Saving a SQL query in xml    forums.oracle.com

I'm writing a program that reads in an xml file that is storing some SQL queries. The user can then select a query and it will run the query on the database and present them with the results. I am running into a problem though and I have narrowed it down to this query: SELECT NAME, (PO.AMOUNT-P.AMOUNT) AS BALANCE FROM VENDOR ...

58. Problem with SQL query never completing    forums.oracle.com

In the given code snippet there may be two issues. Either you're not connected to the DB properly or your query is wrong. (or both) you can try couple of things. 1. Test whether any query is getting executed. Use some simple SQL query like "select current_date from dual" (Oracle), and see if you are able to get "works" printed. If ...

59. sql query    forums.oracle.com

60. Progress bar and sql query    forums.oracle.com

61. Updating many values in SQL?    forums.oracle.com

62. how to parse sql queries embedded in java code??    forums.oracle.com

i m devloping a java code analyzer. So i need to find how many queries are thre in a java file. e.g. java code private String getUpdateQueryForAppFileNo(PersonalDTO personalDTO) throws Exception { StringBuffer sBuffer = new StringBuffer(300); sBuffer.append("update LOS_APP_APPLICATIONS set LAA_FILENO=(Select LSO_BRANCH_CODE || '"); sBuffer.append(personalDTO.getProductId()).append("' || '").append(personalDTO.getApplicationID()); sBuffer.append("' from LOS_SEC_OFFICE where LSO_OFFICE_CODE_C=").append(personalDTO.getBranchId()); sBuffer.append(") where APP_ID_C ='").append(personalDTO.getApplicationID()).append("'"); logger.debug(sBuffer.toString()); return sBuffer.toString(); }

63. SQL update    forums.oracle.com

64. Parsing SQL queries    forums.oracle.com

Hi guys In our application, we have a class representing SQL queries. I am tasked with writing a tool to convert SQL query Strings to instances of our class. Has anyone ever tried something similar? The queries won't be extremely complicated, so I'm not sure if using something like [Jack|http://www.javaworld.com/javaworld/jw-12-1996/jw-12-jack.html] will be worth the effort when I can try to write ...

65. sql query in java    forums.oracle.com

66. Need help to understand SQL queries from DAOImpl class    forums.oracle.com

Now the answers and suggestions I need. 1. what are they doing with the queries in UserDAOImpl 2. how could I analyze the tables and their relationships??? Somebody asked me to use Toad or something. But how and to do what? 3. how could I relate these tables of the CRM Admin Console with the Promo Admin Console which I need ...

67. SQL Query / Insert Builder    forums.oracle.com

I am making a Java program to access / update a database via JDBC. I need to make string queries like this: db.update( "INSERT INTO sample_table(str_col,num_col) VALUES('Ford', 100)"); The query above is simple, but you can see how assembling the query made out of constant string fragments and variables that my program updates can become more complicated. For example, I need ...

68. how to determine a sql query size to display a progress bar    forums.oracle.com

I would like to show a progress of an sql query within a jsp page. Background: I have a reporting web application, where over 500 contacts can run reports based on different criteria such as date range.... I current display a message stating 'executng query please wait', however the users (hate users) do not seem to wait, thereofore they decide to ...

69. An sql query is not working    forums.oracle.com

1.) Always post the exception, error message and whatever detail you've got when something "doesn't" work. 2.) Always use PreparedStatements to execute parameterized queries/updates instead of dynamically building the String 3.) INSERT INTO doesn't have a where clause. Why don't you simply make the wort_text column unique and simply try to insert. If there's already such a word then you'll get ...

70. Update SQL query    forums.oracle.com

but that query is hanging the execution of the program.the program gets stopped there. The same query when executed in the SQL client its working. Doesn't sound right to me. The SQL client isn't that much different from the JDBC call in that it's basically issueing SQL over the network. The only difference would be the protocols I guess and that ...

71. Updating SQL problem    forums.oracle.com

String[] vals = request.getParameterValues("Quantity"); Statement statement = null; ResultSet rs = null; try{ PreparedStatement ps = connection.prepareStatement("UPDATE SelectedItems SET Quantity=? WHERE LotID=(SELECT max(LotID) FROM SelectedItems)"); for (int i = 0; i

72. SQL UPDATE does not work    forums.oracle.com

Hey Guys, I have an update sql query which does not work with PreparedStatement object. Heres the code snippet: PreparedStatement pstmt; int numUpd; pstmt = con.prepareStatement( "UPDATE item_articles SET dataFile=? WHERE itemID=?"); con.setAutoCommit(false); pstmt.setBinaryStream(1,fis,(int)file.length()); pstmt.setInt(2,item.id); numUpd = pstmt.executeUpdate(); con.commit(); What I am doing here is that setBinaryStream(...) will upload a file into the DB. The query executes, theres no exception thrown, ...

73. Executing SQL query    forums.oracle.com

Actually, when I am doing is creating an account by having the user enter information and when clicking the button, the values entered will be compiled into a SQL statement that will be executed to create the user account. Would it be good practice to create the account and to ensure that it was created completely do a SELECT statement to ...

74. SQL problems with I/0 (updating)    forums.oracle.com

Can you print out the updateString string in full and give it a good look? Error messages tend to only report a portion of the string, and the actual syntax error in the SQL may be earlier in the string. Again, have your app print out updateString, so that you can examine the string you are generating to see if it ...

75. SQL Queries    forums.oracle.com

Hi All, I needed a help to decide which is the best practice to use the SQL queries. In my Java Class i dont want to use the sql queries hard coded. I dont want to go for a constant class also. Would it be feasible to use the property file for this? ........ or i can go for some XML ...

76. Java with SQL LIKE query, correct syntax?    forums.oracle.com

77. sql query    forums.oracle.com