mysql 1 « mysql « Java Database Q&A





1. Streaming large result sets with MySQL 4.1.x + Connector/J    stackoverflow.com

I’m trying to get a large result set to stream and having no luck. The MySQL docs are somewhat unclear as to whether this should even work. E.g.:

When using ...

2. Best way to validate user input JDBC?    stackoverflow.com

Is there a built-in way to escape user input in java using the JDBC? Something similar to the php version mysql_real_escape() function. What's the best way to validate input?

3. Foosball result prediction    stackoverflow.com

In our office, we regularly enjoy some rounds of foosball / table football after work. I have put together a small java program that generates random 2vs2 lineups from the available ...

4. Datatype of SUM result in MySQL    stackoverflow.com

I'm having a bit of a problem with converting the result of a MySQL query to a Java class when using SUM. When performing a simple SUM in MySQL

SELECT SUM(price) FROM cakes ...

5. Is jdbc by itself compatible with mysql    stackoverflow.com

I'd like to know if jdbc by itself is compatible with mysql or do I have to intsall something extra? I was told it is not compatible and that I'd have ...

6. What is difference between autoReconnect & autoReconnectForPools in MySql connector/J?    stackoverflow.com

In the configuration reference for MySql's connector J driver, a caveat emptor is issued on the use of the autoReconnect property. I followed the instructions and increased my server's ...

7. How do I use interact with MySQL using Java?    stackoverflow.com

I'm assuming I need to use Connector\J and JDBC to achieve this, but I can't seem to 'install' Connector\J using the CLASSPATH thing. How do I do that ? I use ...

8. problem while importing the data from text to mysql    stackoverflow.com

I have used an application to import some data from a text file to mysql. I have used the following code.

try
{
   stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
      ...

9. How to deliver a Java program locally through a browser    stackoverflow.com

I want to write an application that runs entirely locally on one machine - there is no need for connection to the internet or to any external machines. I was thinking that ...





10. mysql monitoring and management    stackoverflow.com

i want to monitor and manage mysql database sever with jmx. when i hit google it display connector/mxj. i get it and execute MysqldHtmlAdaptor file. it shows mysql server variables. but ...

11. create mysql database from java    stackoverflow.com

Is there any possability to create a database within mysql from java. I'm only aware of the

String url="jdbc:mysql://localhost:3306/test";

Connection con = DriverManager.getConnection( url, "cb0", "xxx" );
syntax but here you have to specify ...

12. How to fetch current year and month from MySQL in JAVA?    stackoverflow.com

I want to fetch the records from MySQL for the current year and month. I am passing to get the today records Today: ("recDate","=", new Date()); Like that, how to fetch for current Month and ...

13. Access mysql on netbeans    stackoverflow.com

I tried to do this tutorial http://www.linglom.com/2007/12/05/accessing-mysql-on-netbeans-using-jdbc-part-i-create-a-connection/ but it gives me an error. I searched to understand what the error means, but i don't know. the error said :

Class ...

14. Restore MYSQL from CMD line using Java Environment    stackoverflow.com

I am using Java and Mysql for a Program, I am Using a Script File in order to restore a Databsae. Under Java I am Executing a command:under bin: mysql -u root ...

15. speed up operation on mysql    stackoverflow.com

I'm currently writing java project against mysql in a cluster with ten nodes. The program simply pull some information from the database and do some calculation, then push some data back ...

16. mysql float type    stackoverflow.com

hello i am having a database order with price and deposit fields set to float type. iam also implemeting a java gui to search the order , the problem is when i ...





17. JDBC with MySQL really slow, don't know why    stackoverflow.com

I have a problem with a really slow connection between my Java code and a MySQL Database. I don't know where the bottle neck is. My program is more or less a ...

18. Distributed Lock Service over MySql/GigaSpaces/Netapp    stackoverflow.com

Disclaimer: I already asked this question, but without the deployment requirement. I got an answer that got 3 upvotes, and when I edited the question ...

19. store into mysql Meduimtext and largtext    stackoverflow.com

when I want store variable in Mysql using JDBC what type shoud I get for mediumtext and larg text? can i get String or must get Byte[]?

20. Getting Random behaviour for a store procedure in mysql    stackoverflow.com

Hi friend I am using MySQL as my database and java as frontend. I am using stored procedure if I want to retrieve the data. There is no synchronization concept. If I want ...

21. Is MySQL Connector/JDBC thread safe?    stackoverflow.com

Is the standard MySQL JDBC driver thread-safe? Specifically I want to use a single connection across all threads, but each statement will only be used in a single thread. Are there ...

22. What's the simplest way to store data from a java program to MySQL?    stackoverflow.com

I want to store data in string form to MySQL. I have created the tables in the MySQL. I haven't worked with DATABASE ever. Can you please provide me code to store ...

23. mysql/jdbc function in out param    stackoverflow.com

So i need to run a jdbc call that is going against a sql server database.

CallableStatement cs = conn.prepareCall("{ ? = call " + spName + " ( ?, ...

24. How to sort the MySql Database?    stackoverflow.com

I have stored various records in the MySql database "orkut". Now I want to sort that database through a java program. I have connected to the database through the jdbc driver. Now ...

25. How to store data in MySql through multiple threads?    stackoverflow.com

I have started five threads from main() function. I have written three funtions as follows:

getConnectionToDatabase();
saveToDataBase();
closeConnection();
Now I want that main function should establish a connection to the database before starting those five threads ...

26. What is best approach for Storing data into MySQL after Parsing XML file using SAX Parser?    stackoverflow.com

I have student.xml file and am parsing this file using SAX Parser and now I need to store data into MySQL Database and so what approach is recommended. Code:

package sax;

 ...

27. Java with database storage    stackoverflow.com

I have to write a program that can take bookings, store them and then access them at a later time, the application has to be written in Java. Because of this ...

28. Plagiarism Analyzer (compared against Web Content)    stackoverflow.com

Hi everyone all over the world, Background I am a final year student of Computer Science. I've proposed my Final Double Module Project which is a Plagiarism Analyzer, using Java and MySQL. The ...

29. WhichdDatabase would prove efficient?    stackoverflow.com

I have to develop a web application in Java, a pretty big one with loads of data to store and manipulate. I am also planning to use Hibernate and Spring. There are ...

30. how to insert/retrieve a userDefined Object in DB-MySql?    stackoverflow.com

I want to insert and retrieve a a user defined Object in DB,am using Mysql5.1. 1)What should me the data type for the column(is Blob is the correct answer for this ...

31. Web Application with Sample "guest" data    stackoverflow.com

we are currently working on a new web application using Java and MySql. We would like to implement a "guest" login feature. The idea is simple: anyone can login as a ...

32. Using info from a database as variable values    stackoverflow.com

I am working on a java project and I need to pull some values out of a database and turn them into variables the program will then use to make a ...

33. Escaping an apostrophe in Java    stackoverflow.com

I'm still somewhat new to Java and trying to insert data into a database. I'm getting an error when inserting a string containing 's so my end result would be to ...

34. Remote MYSQL Database Access    stackoverflow.com

I have developed an application in java that access remote mysql database. While I am running it by netbeans IDE of system which have running that wamp server. But while i ...

35. MySQL Connector/J Problem    stackoverflow.com

So I've been having issues with the MySQL Connector/J driver not correctly loading in a Java Web Start application that is running on Tomcat 6.0.20. I've copied the MySQL connector ...

36. Mysql read data immediately after writing?    stackoverflow.com

I am using a MySQL DB and a Java JDBC client to access it. I have a Table that contains session information. Each session is associated with a SessionToken. This token ...

37. Godaddy Java support and Confusing and Many problems    stackoverflow.com

Could any body please help me ? I called godaddy several time and still no proper answer. Problem 1) Hosting Plan :- I asked for Java linux unlimited host plan and initially ...

38. need some films for knowing how can I use MySQL?    stackoverflow.com

I am beginner in java and I don't know how can I use database and MySQL??and how can I write a code with data base:((

39. Using MySQL and database and having this stacktrace    stackoverflow.com

I have these two classes in my database package:(DBManager and TaskManager class) and I create a new object in my main frame which is in the other package and I also imported ...

40. Why I have NullPointerException here?    stackoverflow.com

I have created a class which name is Manager and I have a Frame which name is BirthList and this frame has a table.I work with MySQL and I have entered ...

41. how to replace hardcoded number with variable in java - mysql code    stackoverflow.com

how can i replace hardcoded number with variable in this java statement which is accessing the mysql datatabase using jdbc. the query is executed using executeQuery(query) here is the java statement

String query ...

42. Importing a (mysql) database dump programmatically through Java    stackoverflow.com

How can I import a mysql database dump file (contains insert and create table statements) programmatically through a java program. I need this as the setup phase of a unit test. ...

43. How to Call Java Code from MySQL?    stackoverflow.com

I found an article from 2008 discussing how to call Java code from MySQL. There were a lot of caveats and disclaimers because the process involved working with an ...

44. Read a large result set in chunks from mysql    stackoverflow.com

I am trying to read a huge result set from mysql. Reading them in a straight-forward manner didn't work, as mysql tries to return all results together, which times out. I found ...

45. Is there any extremely tiny CMS in Java with MySQL?    stackoverflow.com

I'd like to explore some things regarding web CMS's in java and I would like to make an own one (very light), but I pretty much have no clue in how ...

46. Liquibase diff generates changeset using wrong case on tablenames    stackoverflow.com

I'm performing a diff on a remote mysql database using LiquiBase, and finding that the changeset that is generated uses the incorrect casing for table names (all lowercase). This subsequently ...

47. Java: DB Communications Link Failure    stackoverflow.com

My program that connects to a MySQL database was working fine. Then, without changing any code used to set up the connection, I get this exception:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet ...

48. Java Threads and MySQL    stackoverflow.com

I have a threaded chat server application which requires MySQL authencation. Is the best way to have 1 class create the MySQL connection, keep that connection open and let every thread ...

49. Java Application to show a lot of charts and stats, storing the data?    stackoverflow.com

I'm working on a Java application, one of its functions is to show detailed information in graph form with the odd statistic and "top 10" list here and there. The data is ...

50. Are there any good CachedRowSet implementations other than the proprietary Sun one?    stackoverflow.com

I am investigating using javax.sql.rowset.CachedRowSet in part of my application, however I can only find information on using the proprietary sun implementation com.sun.rowset.CachedRowSetImpl or Oracle specific implementations. The ...

51. MySQLNonTransientConnectionException in jdbc program at run time    stackoverflow.com

Hi I have created jdbc mysql connection. my program works fine for simple execution of query. But if i run the same program for more than 10 hour and execute query then ...

52. Zookeeper/Chubby -vs- MySql NDB    stackoverflow.com

I have been reading the Paxos paper, the FLP theorem etc. recently and evaluating Apache Zookeeper for a project. I have also been going thru Chubby (Google's distributed locking service) and ...

53. random numbers in java    stackoverflow.com

I have the following table created using java as the front end and mysql as the backend.

mysql> select * from consumer9;
-------------           ...

54. How to run a java program on a server?    stackoverflow.com

I have made a java application that stores data from a .csv file to a MySql database. Now my client want it to upload this application to his web space (web ...

55. Am I using Java PooledConnections correctly?    stackoverflow.com

I want to use pooled connections with Java (because it is costly to create one connection per thread) so I'm using the MysqlConnectionPoolDataSource() object. I'm persisting my data source across ...

56. How to Create a MySql Database using JDBC    stackoverflow.com

Can we create a new MySQL database( not a table, I want a new database) from java code ? I have searched the internet and I get code only for connecting ...

57. command to export mysql database to a file    stackoverflow.com

I am want to export database table to a file.
I am using the following code, but it gives the following error. ...

58. How would you go about improving MySQL throughput in this simple scenario?    stackoverflow.com

I have a relatively simple object model:

ParentObject
    Collection<ChildObject1>
    ChildObject2
The MySQL operation when saving this object model does the following:
  • Update the ParentObject
  • Delete all previous items from ...

59. How do I ensure data consistency in this concurrent situation?    stackoverflow.com

The problem is this:

  • I have multiple competing threads (100+) that need to access one database table
  • Each thread will pass a String name - where that name exists in the table, the ...

60. DB.Null equivalent in JDBC    stackoverflow.com

Is there an equivalent of (ADO.NET) DB.Null in JDBC? Or do I simply pass null in the parameter? Particularly in the context of Mysql?

61. Store HTML into MySQL database    stackoverflow.com

I'm trying to store a String which contains HTML in a MySQL database using Longtext data type. But it always says "You have an error in your SQL syntax". I tried ...

62. How to migrate data from FoxPro to MySQL    stackoverflow.com

I am having a database in .dbf (FoxPro) format.

  1. How to retrieve data from FoxPro using Java?
  2. If the data can be migrated to MySQL, How to do the conversion?

63. want to store Object in MySQL database    stackoverflow.com

I have a variable in java which return type is Object(java.lang.Object). I want to store this variable value in MySQL database without casting in any other primitive data type. Is there ...

64. Can't select data from MySQL database: java.lang.NullPointerException    stackoverflow.com

I'm trying to select data from database using this code:

//DATABASE
ResultSet rs;
String polecenie;
Statement st;
String[] subj;

public void polacz() {
    try {
        Class.forName("com.mysql.jdbc.Driver");

  ...

65. How do you catch a MySQLIntegrityConstraintViolationException correctly?    stackoverflow.com

I am working on a web application, and at a point where I submit forms that are unique to the user, a

 MySQLIntegrityConstraintViolationException Duplicate entry -'username' 
for key 'PRIMARY'
I am ...

66. A MySQL schema parser in Java?    stackoverflow.com

Does anyone know whether there is a java library for parsing a MySQL schema? In code I want to be able to determine the tables and fields specified in a schema. ...

67. How to inherit from the main class in java    stackoverflow.com

I have two java classes. One is NewFrame.java where the forms(buttons, textfields) are located. And the other one is Main.java where I have put the connection string for mysql: Main.java looks like ...

68. Limit MySQL requests    stackoverflow.com

Context: A Java client-side application needs to access a server-side MySQL database. Need: Limit the possible number of requests to the database for each client (based on the client's IP). Question 1: Is ...

69. Storing HTML in MySQL using Java    stackoverflow.com

So, I'm working on a project now where I should store webpages inside a database, I'm using crawler4j to crawl and Proxool along with MySQL ...

70. How can I add "set names 'latin1'" in jasperreports    stackoverflow.com

I have problems with some character display, like "ñ" and accents in my reports, so I want to add previously to the query "set name 'latin1';" but jasper doesn't work, ...

71. GPLv3 License use case    stackoverflow.com

If I use Tigase(xmpp server demon) on my server (not distributing it) and build custom plugin(stay within server). Do I have to release my source codes? What if my website have ...

72. Force MySQL 4.1 return to Decimal type    stackoverflow.com

I'm using JDBC to access a MySQL 4.1 database and have problems with queries of Decimal type. When I do a query on a single Decimal column (i.e., SELECT amount ...

73. How to use mysql IN comparison function with JDBC    stackoverflow.com

This seems simple, but it is impossible to search the web for... I have a legacy application that uses JDBC directly with no frameworks, and I'm having to add some new features. ...

74. Should I need to release my application if I include MySQL Connector/J (GPL) as part of my package?    stackoverflow.com

I am using MySQL Connector/J (GPL licence) and bundle the jar as part of my distribution. So should I need to release my application under GPL also?

75. mySQL jar name and location    stackoverflow.com

I wanted to know, What jars do I need to have to connect to MySQL, and Where can I download it? I googled it but there are so many of'em. Can somebody ...

76. Can I load mysql data trunk by trunk in java?    stackoverflow.com

Currently I am using statement.executeQuery(qStr) in java to select a large amount of data from mysql. Unfortunatly, java keeps running out of memory at the statement.executeQuery(qStr) statement with exception java.lang.OutOfMemoryError: Java ...

77. Using Sesame 2 and MySQL in my Java Class    stackoverflow.com

It's my first time with Sesame 2 so please be kind. It could be a stupid question but I can't find documentation about how to use Sesame 2 and a mysql ...

78. Using Java (HTMLUnit) to Scrape a Web Page then Write Results to a mySQL Database    stackoverflow.com

I've been able to use Java and HTMLUnit to scrape a web page, however I'm unsure how I can get this to write the resulting data to a MySQL database on ...

79. Obtaining metadata from MySQL in Java    stackoverflow.com

Possible Duplicate:
How to get equivalent of ResultSetMetaData without ResultSet
StringBuffer queryBuffer=new StringBuffer("SELECT * FROM "+tableName);
PreparedStatement preparedStatement=getConnection("root", "").prepareStatement(queryBuffer.toString());
ResultSet resultSet=preparedStatement.executeQuery();
ResultSetMetaData resultMetaData=resultSet.getMetaData();
from the upper code I got ResultSetMetaData ...

80. Fetch a Web Page and save in Database?    stackoverflow.com

How can i fetch a HTML page and save it to my database in JAVA?is there any easy way to do that?

81. Where to begin with a java project    stackoverflow.com

I've tried searching for similar questions here and I don't think I've found anything that matches what I'm looking for. I would like to know where to start in developing a ...

82. 2 man project - java+database programmers    stackoverflow.com

My friend and I are entering our final year at the university (M.Sc.) in 2 months and as such we have to start thinking about our dissertation (as we decided to ...

83. how to resolve a Bad format for Time problem in java?    stackoverflow.com

i'm working with java to extract values of a time column in table in mysql. the code below show the query i do send.

String query="select id,time from table where Hour(time)<=32 ";
ResultSet res ...

84. import/export db configuration    stackoverflow.com

We have a java portal connected to a mysql db containing about 70 tables. When we prepare a new client on it, we test it on a DEV server and if all ...

85. Quering and writing to a file : errorcode 28    stackoverflow.com

I am getting this error when I try to query the database and write results to a file. It never occured before.

java.sql.SQLException: Error writing file '/tmp/MYwADPLw' (Errcode: 28) ...

86. How to check for null value for a double which is taken from a database    stackoverflow.com

I am extracting values from a database. I am extracting a double value from a database using

ResultSet rs = ....;
while(...){
  rs.getDouble("num");
}
How do I check if the value of rs.getDouble("num") ...

87. Can I ignore or suppress warnings in JDBC for MySQL?    stackoverflow.com

I have an INSERT INTO ... ON DUPLICATE KEY UPDATE ... statement that executes fine (but with warnings) in the mysql> prompt:

mysql> INSERT INTO ... ON DUPLICATE KEY UPDATE ... ;
Query ...

88. Java - Communications Link Failure    stackoverflow.com

I just talked to my host that I have my web page at and they say they allow JDBC connections. Anyway, the page you can view this at is http://mystikrpg.com/mysqltest/mysqltry.html Here ...

89. How can I get a custom CallableStatement object out of a prepareCall method    stackoverflow.com

I want to create a subclass that extends the CallableStatement object. I want to do this so I can override the execute and executeQuery methods to track some metrics on ...

90. Created a Java Web app/MySql app    stackoverflow.com

Started coming up with a java web app for online user interaction. Decided to use a MySql DB for data storage. I have already created the tables with the proper/expected data ...

91. database and java    stackoverflow.com

i am a student. i have to do the individual project about a system. the system must be done using the console not the web base. so i`m using netbeans version ...

92. How to account for an unknown return type for a Java Function    stackoverflow.com

I have a function that returns the result of a query. The input arguments are the SQL statement and the field to be retrieved, while the output is the result of ...

93. Java MySQL Programming    stackoverflow.com

I am accessing a MySQL table that has over 1 million or more Records. I am using My SQL query browser which is unable to grab all the records and it ...

94. Java long to Mysql    stackoverflow.com

What is the equivalenf of a Java long in the context of Mysql variables?

95. Calling MySql functions remotely fails    stackoverflow.com

When I try to call user defined functions using remote connection it gives me error. The thing is query without any functions runs fine for remote connection. So how can I call functions ...

96. Java never recieves data from mysql    stackoverflow.com

Hi Lately i have been having some trouble with connecting to mysql from java. Mostly everything works fine. But sometimes, the query takes forever, it is a pretty hard query and it should ...

97. Calling MySQL database using Java    stackoverflow.com

Hi I am new to programming and trying to call a table from a MySQL database using Java. Here is what my Java code looks like:

public static void main(String[] args){ ...

98. Code snippet to parse mysql output from Java    stackoverflow.com

I'll write it, but if there's a ready, tested code snippet that does this I'll be happy to steal it.

COUNT(*)    SUM(cnt)
0   1
Edit - Thanks for the ...

99. Communication failure during handshake. Is there a MySQL server running on localhost:3306    stackoverflow.com

i am using below code

try {
            Class.forName("org.gjt.mm.mysql.Driver");
            conn = ...

100. data parsing from a file into java and then into a mysql database    stackoverflow.com

I have .Data file given in the above format . I am writing a program in java that will take the values from the .data file and put it in the ...