String « Operation « Java Database Q&A

1. java regex to split an attribute list from an sql query into a String[] of attrs

currently I have the following code:

String select = qry.substring("select ".length(),qry2.indexOf(" from "));
String[] attrs = select.split(",");
which works for the most parts but fails if given the following:
qry = "select a,b,c,DATETOSTRING(date_attr_name,'mm/dd/yyyy') from tbl_a";
what ...

2. Like %?% doesn't work as part of StringBuilder SQL query

Have following String built SQL query:

    StringBuilder querySelect = new StringBuilder("select * from messages ");
    StringBuilder queryWhere = new StringBuilder("where msg_id=?");


3. JDBC SQL query string problem

Im having some issues inserting a sql query into java as a string. When I paste the text straight in it doesnt keep it as a string (not sure why because ...

4. How to sort the strings and insert into sql table in JAVA

In an excel sheet, i have 2 columns (first is the parent and second is child) like

Parent    Child

BHW      ...

5. how do i pass multiple string value to an ibatis custom query

SELECT  *from ks,lk
WHERE     (Category_Code = #category#) AND Item_Code = #item_code#)
AND  (Return_Data.Institution_Code NOT IN (#bankCodes#))
I want to pass a collection of many value in the not ...

6. Database query string issue

Hi Guys, I am new to Netbeans but am a seasoned .net developer. I am creating my first JForm with db connectivity, all is well until the query executes and then it fails. The issue is that when I run the query within sql developer I use quotes around the table: SELECT "Col1", Col2" FROM "T_Test" when I run the file ...

7. sql inserting large String

hi, maybe the reason is just that VARCHAR is limited to 255 chars while TEXT is unlimited (in some sort - i mean: i don't know what's its limit ;-) ). so if your setting the datatype to some varchar thing, change it to TEXT. (sorry, if thats way out of the range of your question, you didn'tspecify any size.) chantal ...

8. Why the string inserted become longer?

I've encounted a strange problem, When i use store procedure to insert a record, the string value expanded to the length of parameter length. for example, I declared the procedure like this the Database is MS SQLServer, the driver is JDBC-ODBC bridge)

 CREATE PROCEDURE [up_NewFwxxInfo] @strBlockName varchar(100), AS insert into tbl1(BlockName) VALUES (@strBlockName) 
and i call the procedure like ...

9. Inserting strings with quotes

10. using Strings to query database??

14. building a dynamic Query String

15. error in inserting string into database

Hello pals, this is a code snippet in which I insert two strings into MSACESS .while Im able to insert the string myname,Im not able to insert pc.Is there any problem with making more than one prepared statement on a connection object or is it some silly sql syntax error? public void storePhone(String x,String y){ myname=x;pc=y; try{ System.out.println("in storephone pc="+pc); String ...

17. Save a query to a string

Hello I have used these forms to answer many questions but finally I have a question that I am unable to find the answer to. I am trying to query a database 3 records all in one row inside a table. Then take the results and save them to a String. The table has 4 columns with data in them: User1, ...

18. Insert Default Columns if the String length is 0?

Hello guys, I'm actually having an JSP Form in a single page. Well, we can say it is a static one. But my case here is that, if there's nobody enter any value into the form... Then the textfields there would be a STRING that has a length of 0. Thus, I wanted to use that NOT To be stored into ...

19. How to create dynamic query string

Hello, I am thinking to make one select, update and insert query dynamically despite to use them with different column names every time in the project. For example I want to do 1) how many Strings and Integer parameter will be passed 2) then these number of parameter will be set as method parameters e.g. public String query(int i1, int i2, ...

20. How To insert non-english Strings to Database

Hello , I need to insert non-english Strings into a database , i am using mysql database, and the non-english text is "arabic" Now i set the collation of my database,tables and fields to "utf8_general_ci" anyway , i have no problem reading from database in to the application. it reads arabic text successfully , the problem is when i try to ...

21. How to apply string from java to SQL query?