Query 1 « mysql « Java Database Q&A

1. How to set a list of integers while preparing SQL queries in Java    stackoverflow.com

I have a query like this - select * from tbl where ... and colname in (2,3,4) When I prepare the query (... ' colname in (?)' ) using a PreparedStatement ...

2. Java - Ibatis - mySQL with Dynamic Query based on Role    stackoverflow.com

I'm using Java - Ibatis and mySQL with Flex/Flash on the front-end. I have one requirement that is to be able to dynamically add creterias and table to a query ...

3. What tool can suggest index and covering indexes for dynamicly created queries?    stackoverflow.com

Our web application basically dynamically generates tables and relations. It also generate indexes on the basic level. We are looking for a MySQL profiler that will be able to ...

4. SELECT 1 from DUAL: MySQL    stackoverflow.com

In looking over my Query log, I see an odd pattern that I don't have an explanation for. After practically every query, I have "select 1 from DUAL". I have no ...

5. jdbc returns mySQL syntax error exception for a valid query    stackoverflow.com

I user the java.sql.Statement.excecuteUpdate method to create a table and insert some values into the database through JDBC. However, it gives me MySQL syntax exceptions for no reason. I copied and ...

6. SQL Injection in Java/MySQL - multiple queries    stackoverflow.com

I've got a web application with an SQL injection as part of an INSERT statement, it looks like this: INSERT INTO table1 VALUES ('str1', 1, 'INJECTION HERE') I can insert the regular multiple-query ...

7. how to join or Union result of 2 sql queries in single result set    stackoverflow.com

i have 2 tables(result of two separate SQL queries and this result will be contained by List<Object> where each object represents 1 row of the database ) Table_1

  • Dimension_1
  • Dimension_2
  • Fact_1
  • Dimension_1
  • Dimension_2
  • Fact_2
I want to join these ...

8. suggest a link with such concepts implemented - java and mysql    stackoverflow.com

i need to write a program in java that will connect to a mysql database and execute some sql queries and display the result. suggest me a link with similar implementation ...

9. mysql query which selects from another mysql query    stackoverflow.com

i am migrating from ms access database to mysql database with java frontend so that my application can be used in linux as well . in ms access here's what i ...

10. java - mysql - select query outfile - where is file getting saved    stackoverflow.com

connecting to a mysql database from java using jdbc. declaring a query

String query = 
        "SELECT *"+
        "FROM ...

11. why does mysql inner join query take so much time    stackoverflow.com

in mysql i have two tables


col1   col2  SIM1 ..........col24
a       x     1        ...

12. Why do I get \N when executing INTO OUTFILE query?    stackoverflow.com

I am connecting to a MySQL database using Java. I am executing this query:

    String query = 
        "SELECT ...

13. MySQL like query runs extremly slow for 5000 records table    stackoverflow.com

I have this issue on our production server. The application stack is,

  • Java Web App on Tomcat 6.0.18
  • iBatis data access layer
  • MySQL 5.0 database
  • CentOS
The system is deployed on virtual server having around 256 ...

14. sum and union all query using mysql and java    stackoverflow.com

I have a table with following fields Service_type and consumer_feedback.for example:

Service_ID  consumer_feedback
31           1
32         ...

15. Database queries in Java    stackoverflow.com

How can I connect to MySQL db and execute queries ?

16. how to get mysql query result as xml?    stackoverflow.com

I recall reading about XML support from MySql. Does anyone know how to get XML without writing code? My client-protocol expects XML and I have a data source that ...

17. Datatype query on datetime and tinyint    stackoverflow.com

I have a Mysql datetime column, what should be the corresponding datatype in a java entity bean class for this column? What would the java-type be for a Mysql tinyint?

18. Specifying a variable name in QUERY WHERE clause in JDBC    stackoverflow.com

Could someone please give me a link on how to create a query in JDBC that gets a variable name in the WHERE statement, or write an example, to be more ...

19. Jdbc Template and MySql interaction for Frequently Changing Queries    stackoverflow.com

There are some queries used by a DAO layer that is implemented in JDBC Template

String longQuery = ".....";
public List<AnObject> findObjectsBySomething(Something s) {
    return getJdbcTemplate().queryForObjects(longQuery, myRowMapper, s);
longQuery is going ...

20. sql query to incrementally modify where condition until result contains what is required    stackoverflow.com

I need an sql query to select some items from a table based on some condition which is based on a category field. As an example consider a list of people and ...

21. Can I get the full query that a PreparedStatement is about to execute?    stackoverflow.com

I'm working with PreparedStatement with MySQL server. example:

String myQuery = "select id from user where name = ?";
PreparedStatement stmt  = sqlConnection.prepareStatement(myQuery);
stmt.setString(1, "test");
ResultSet rs = stmt.getResultSet();
How can I receive the full SQL ...

22. How to set Timeout for a mysql query in Java?    stackoverflow.com

I want to set some timeout for a mysql query to execute in java.

23. Dymanic Query in Ibatis    stackoverflow.com

Is it possible to pass dynamic query to Ibatis and get the record from it? E.g. I built my query using StringBuilder and at last, I got the following query "select emp_id, ...

24. JDBC (mysql) saves queries in heap memory    stackoverflow.com

I am trying to run Hibernate Search on database on a table with 12,500,000 records. On startup, Hibernate Search queries the database to obtain the schema information. The problem is that I get ...

25. Java: MySQL query. Get generated ID    stackoverflow.com

I have a table that contains a column called 'id' that is an INT that auto increments and is set to be the primary key. I need to get the value of ...

26. Can I use multiple statements in a JDBC prepared query?    stackoverflow.com

I'd like to execute something like this on my MySQL server:

SET @id=(SELECT id FROM lookupTable WHERE field=?);
(SELECT * FROM table2 WHERE id=@id)
(SELECT * FROM table3 WHERE id=@id)
(SELECT * FROM table4 WHERE ...

27. jdbc - java - method query    stackoverflow.com

I am using JDBC to query a MySQL database for specific records from two tables. My MySQL query sample is this:

  , r.network
  , r.namestring
  , i.name
  , ...

28. mysql query for timezone conversion    stackoverflow.com

is there a way to convert from unix timestamp to GMT in mysql while running the query itself?? My query is as follows:

  , r.network
  , ...

29. improving speed of query processing    stackoverflow.com

having major issues with my query processing time :( i think it is because the query is getting recompiled evrytime. but i dont see any way around it. the following is the query/snippet ...

30. Connection pool query results jumping between live and old data?    stackoverflow.com

I'm developing a Java SE application with a MySQL database. It uses a connection pool of size 10 as there are many screens. Each screen has a Thread that will update ...

31. Select Query Optimization    stackoverflow.com

I have select query that fetch record based on a condition

Select * from Employee where EmpStatus=#EmpStatus#
The EmpStatus in the DB for each employee would either 0 or 1.
EmpID EmpName EmpStatus
1  ...

32. In Java, how does PreparedStatement work for the following query    stackoverflow.com

I have a query like the following and was wondering what kind of SQL is produced by batching a PreparedStatement.

INSERT INTO table1 (id, version, data)
  VALUES (?, ?, ?)

33. query in Sql with JDBC    stackoverflow.com

In my table, I have taken capacity in this form. `capacity DECL(3,0) UNSIGNED Is it correct??I am not sure if the above method is correct to do it in this way? if ...

34. sql query via jdbc    stackoverflow.com

Possible Duplicate:
sql query with jdbc
How dow e find the wuery frok mysql.

35. Is this mysql query right or wrong?    stackoverflow.com

   "select full_name from user u join user_contact_info ui on ui.user_id=u.user_id,
   ui.user_contact_state, ui.user_contact_city_town, ui.user_contact_country where 
   u.full_name like '"+keyWord+"%'" + "and u.user_id = "+id;
from my ...

36. Java & MySql - How to escape query before execute it    stackoverflow.com

I'm using Java for a web application, and I'm working with a MySql database. I need to escape the query before execute it. This is my actual code :

db_result=mydb.selectQuery("SELECT nickname FROM ...

37. viewing results of mysql query in java    stackoverflow.com

In java, when executing a query like : statement stm = stm.executeQuery("select * from table1"); How can I view the results of this query on the command prompt ? Thanks for any help ...

38. Database Query to get sum of count from different tables in a single query    stackoverflow.com

I am writing a query in Mysql database, in which Query 1 returns count() say result is 10 and Query 2 returns Count() say result is 30 But I want to get the ...

39. MySQL Query to XML output    stackoverflow.com

Is there a framework current out there that allows you to take MYSQL query output and convert it all into XML?

40. Help with MySql Query    stackoverflow.com

how can one execute two queries at the same time using mysql and java? i am facing a problem with this login i created.the login works just fine.but when it works in ...

41. number of queries limited in mysql    stackoverflow.com

hi I use a java library(jwpl) to connect a database of mysql. number of queries that I can be asked on a certain term is limited. for example query="select * from table where keyword= ...

42. MySQLSyntaxErrorException when creating table    stackoverflow.com

I am fairly new to MySQL with Java, but I have executed a few successful INSERT queries however cannot seem to get the CREATE TABLE query to execute without getting the ...

43. How to check the less than condition in compiled queries of java?    stackoverflow.com

In mysql we can check the less than condition by using '>' symbol but in XML files in java, how can I check that condition when we are writing query? Please ...

44. Java: Making concurrent MySQL queries from multiple clients synchronised    stackoverflow.com

I work at a gaming cybercafe, and we've got a system here (smartlaunch) which keeps track of game licenses. I've written a program which interfaces with this system (actually, with it's ...

45. Hadoop (+HBase/HDFS) vs Mysql (or Postgres) - Loads of independent, structured data to be processed and queried    stackoverflow.com

Hi there at SO, I would like some ideas/comments on the following from you honorable and venerable bunch. I have a 100M records which I need to process. I have 5 nodes ...

46. MySQL in Java: using a LIKE query on a varbinary field?    stackoverflow.com

Basically, I have a table with an indexed varbinary field in it. I want to say: return all rows whose varbinary field starts with (an array of bytes). How do I do this ...

47. in operator in parametrized sql query    stackoverflow.com

i want to search from a set using parametrized sql query for a particular value wheteher it conatin or not than what will be the sql query for this

48. mysql select query in java    stackoverflow.com

I'm new to connecting java with a mysql database. What's wrong with my query here:

PreparedStatement statement = conn.prepareStatement("SELECT * FROM q_table, choices, answers  WHERE q_table.QID='" + number_input + "' AND ...

49. How to test if sql query returned true in java    stackoverflow.com

I have this select query. How would I know if the query has found a match on the database?

        PreparedStatement fetchPlayers = conn.prepareStatement("SELECT * ...

50. Whats wrong with this MYSQL Query    stackoverflow.com

    SELECT * FROM event JOIN user ON event.event_user_id=user.user_id
  WHERE ((event.event_date BETWEEN '2011-03-01' AND '2011-04-01' ) 
    AND user.user_id in (SELECT user_id FROM user_map ...

51. Nested SELECT Query Java + MySQL    stackoverflow.com

I'm trying to get data from DB. I must use to queries. From the first query (In Loop) I get the code of Work codew and the I use it in the ...

52. Problem in count a query in database    stackoverflow.com

Possible Duplicate:
How do I get the row count in JDBC?
Hi, How can I count a query in a row in MySQL database using sql ...

53. JDBC driver for MySQL - Query Wrapping?    stackoverflow.com

a simple question really, for which I cant seem to find an answer and am not going to reconfigure DB to log queries.... The question is: Does the driver automatically wraps all ...

54. can't send more than one query to the server (using jdbc and ocsf)    stackoverflow.com

i'm using JDBC and OCSF to make client-server connection including MySQL.
i'm now stuck at a very strange problem:
my server can receive either "select..." string, "insert..." string, "update..." string (those are treated ...

55. Query a MySQL db using java    stackoverflow.com

Guys, simply put, I have a java application with a text output box. I'd like to query a Db and display the output into a text box. Example I have a ...

56. Problem with query in MySql    stackoverflow.com

String sql = "SELECT siteapplications.Application, Count(visits.VisitId) AS CountOfVisitId 
FROM visits, siteapplications 
WHERE visits.SiteApplicationId=siteapplications.ApplicationID 
and Month(visits.VisitTime)=" + month + " 
and Year(visits.VisitTime)=" + year + 
"GROUP BY siteapplications.Application 
ORDER BY CountOfVisitId DESC;";
rs ...

57. Problem executing query    stackoverflow.com

I have a function which fetches data from database and displays in the JSP in table format.The function is written in java class,which is called in JSP.But the query is not ...

58. Execution time of Queries    stackoverflow.com

I have some queries which executes in MYsql Yog fast. But when the same query is called from java class, it takes a long time. Why is that so? Can anyone explain me the ...

59. query gives different output on different os    stackoverflow.com

I have written the following function in Java. This function returns current timestamp by executing a query. The function code is as follows :

private  String getTimeStamp(){
String timeStamp=null;    ...

60. While executing mysql insert select query- can we do condition check?    stackoverflow.com

I am trying to execute mysql select insert query as below.

Now, if EXPIRYTIME in table2 is null, then i want to update ...

61. MySQL,JDBC query execution too long    stackoverflow.com

I've got database querying that has become too slow with my current implementation. I need to get all movies from a database and for each of these movies i need their ...

62. mysql query in java getBigDecimal(columname) returns always 0.00    stackoverflow.com

I´m trying to make a java mysql query program for an existing database. The thing is I´ve being struggling for the past two days to get BigDecimal values from the database, ...

63. Building Select Query Using IN(...) Clause    stackoverflow.com

I need to do select * based on a list of input ids, what's the best way of batch select? here's what I have

StringBuilder inClause = new StringBuilder();
boolean firstValue = ...

64. java load data infile query discarding wrong lines    stackoverflow.com

Java application insert data to mysql using load data infile query. In csv file, some wrong formatted values like lacking rows, improper fields (string value for integer value). If there is ...

65. How to execute composite sql queries in java?    stackoverflow.com

How can I execute the following query and retrieve a result via prepared statement:

Is there a way to execute both two statements at once?

I've ...

66. Delete query in mysql    stackoverflow.com

I want to delete rows from multiple tables. I know the select query, but I need an exact delete query for all the columns that are defined below:

SELECT j.application_id, 

67. New to mysql, query throwing wrong syntax    stackoverflow.com

I am trying to pass this query from my Java application but it is saying I have an error in the UPDATE line, but i cant find what is wrong? can ...

68. Project Database My SQL and Java, JDBC    stackoverflow.com

Hi Everyone I just need everyones help since I'll be working on a project here my project is I have to create a database, well a simple one Using Open office base(for ...

69. Newbie using Java to query a MySQl and front end it    stackoverflow.com

I found XAMPP today and its good stuff and assembling code for database XAMPP contains PHPMyAdmin and apache for windows. I have NetBeans running and access to MySQL 5.5 too. I have found ...

70. What is the return type of a "count" query against MySQL using Java JDBC?    stackoverflow.com

String query = "SELECT COUNT(*) AS count FROM table1";
ResultSet rs = DBConnection.executeQuery(query);
The above code works fine; however:
long count = rs.getLong("count");
This wont work, it throws SQLException. How ...

71. nested loop wont execute queries in internal loop with length bigger than 1    stackoverflow.com

Sorry guys i couldn't provide feedback because of my other username and password here, anyways here is the issue: I'm working on a SOAP based webservice where in a part of it ...

72. Why is this query not returning any results?    stackoverflow.com

I am leaning some Java for school, and for some reason the code below doesn't return any results? Is there a problem with this code? There is a single record in ...

73. 3 level nested loop query wont run outer loop    stackoverflow.com

I have 3 level nested loop which is supposed to execute a query, part of a bigger webservice but the issue is that the outermost loop is executed only half the ...

74. Multiple values in SELECT    stackoverflow.com

How could i formulate a SELECT query where the values of one of the fields is dynamic, specfically, the values of sintom, which is an array of String,are determined upon execution ...

75. Fetching data after left join query by removing duplicates?    stackoverflow.com

I used a left join query with two tables so I'm getting multiple values for the main table column value in the resultset. How can I remove duplicates in that? Query:


76. How I can return query result from Server to Client    stackoverflow.com

I have a webservice where from the Client-side some parameters are passed to perform a query on the DB, the Server-Side is supposed to carry out the query and return the ...

77. JDBC's rs.getString() won't return the value of the query result    stackoverflow.com

I have some problems with JDBC's rs.getString("column_name") basically it would not assign the value recieved from the query result, I have a String ris which is supposed to get the row ...

78. Geonames database: getting a full hierarchy (country -> admin1 -> admin2 -> city) with one only mysql query    stackoverflow.com

i'm trying to use geonames database (downloaded and loaded on a local mysql) to get all associated informations from a location (lowest level is cityname) using Java and JDBC ...

79. MySql query exception    stackoverflow.com

When i am trying to insert values in MySQL table through java code, I am getting the exception:

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint ...

80. "The result set is closed" error on nested execute query    stackoverflow.com

I want to write a query that should print values for xml tags from database in java.

<employee emp:empid=" " emp:empname="" /><location loc:locname=" "/>
The code below ...

81. Optimising a lot of inserts with JDBC and MySQL    stackoverflow.com

I have to perform a large number of inserts (in this instance 27k) and I want to find an optimal to do this. Right now this is the code that I ...

82. Where to put sql queries? Code style. Java. JDBC    stackoverflow.com

I am working with JDBC driver and my problem is storing SQL queries in a good place. The point is that it will be making a large number of queries.

Statement s ...

83. Set match function in a mysql query with Java    stackoverflow.com

I have the following excerpt from a query (mysql) made ??in java:

queryGeral.append("FROM product p, fabricante_product fp, fabricante f, extensao e,  product_autor pa ")

84. MySQL set a variable and run a query in the same statement/script    stackoverflow.com

I'm have a database customer name and date are the composite keys. I'm trying to pull out the 'x' largest or smallest transactions on each date and insert it into another ...

85. Sql Query statement in operator    stackoverflow.com

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

class test{

def selectAuther(){
    def nameList = []

    con = DriverManager.getConnection("url", "username", "password")
    stmt = con.createStatement();

86. Insert query with latin1_swedish_ci charset    stackoverflow.com

I made a program that is generating me a INSERT queries for a MySql database. The database has 2 fields that are encoded with latin1_swedish_ci charset. If I run the query ...

87. Mysql Error in simple query    stackoverflow.com

For this query I am getting error

"INSERT INTO table " 
  + "(item1,item2) "
  + "VALUES "
  + "(" + number1 + "," + number2 + ...

88. jOOQ insert query with returning generated keys    stackoverflow.com

I installed jOOQ into eclipse, generated classes for my mySQL, but I still have problems to write also some basic queries. I tried to compose insert query with returning of generated ...

89. How can I use Mysql's INET_NTOA through an EntityManager in Java, or simply do this conversion through Java code?    stackoverflow.com

I am trying to manage a network Database through a GUI form in Java. I am running into a problem where the ip addresses are stored in the database in ...

90. Query, Display, and Filter Large Database Lists    stackoverflow.com

I am trying to determine the best method of collecting a large list from a database and then displaying and filtering the results on the client side. Let me give a ...

91. MySQL query result - memcahed using java    stackoverflow.com

I am really new to Memcache. I just tested Memcache in Java and it works fine. I want to store MySQL query result in Memcache key. How can I do this? ...

92. Make a MySQL query faster    stackoverflow.com

I need to make this query faster and need some help. The code is :

sqlFrom = "FROM tx_apartment_buy a where result_id" + 
"not in (select result_id from tx_user_view2" + 
"where product_type='apartmentBuy'" + ...

93. java / mysql / slow    stackoverflow.com

Point here being: 1.SET query_cache_type = 0; RESET QUERY CACHE ; 2.run any query within heidisql(or any other client side UI) --> execution, say 45 milisec 3.run same query with below code ...

94. Beginner: Building MySQL Query from ComboBox Selections    forums.netbeans.org

Have been teaching myself Java for about 6 months now. Working through different tut's, books and using online resources have helped with working through problems a ton. But I now have one I just cannot seem to figure out. So I know it's simple and I admit that I am most likely over-thinking the problem, but here it goes... I have ...

95. Sorting MySQL Slow Query Log    jmeter.512774.n5.nabble.com

97. Mysql query    coderanch.com

98. MySQL query    coderanch.com

Hi all, i am having 3 tables named as follows, products, company, productcategory. i am having a table for storing history os selling.named as productssoldhistory. the fields of productssoldhistory table are, soldhistoryid, productid, date, the fields of products table are, productid, productname, copmanyid, the fields of company table are, companyid, companyname. i wanna select the companyname of 10 maximum sold products ...

99. How to prevent a MySQL slave accepting queries?    coderanch.com

Hi all, If I have a setup with one master and one slave MySQL instance. When the master goes down, the application moves to using the slave instance for its JDBC connections. Now, the problem is that the JDBC connection is quicker than the "stop slave" operation -- that is, after a crash, the application starts pounding the slave server with ...

100. MySQL query and JDBC using "LIMIT"    coderanch.com

I'm not sure if this is in the correct category, but I have a problem from a combination of things that are going on and I'm not sure where the problem actually exists. I was hoping for some insight. We are using Tomcat to call a servlet that uses JDBC to connect to a MySql database. The problem is in the ...