mysql 1 « mysql « Java Database Q&A

Java Database Q&A
7.Data Type
9.Database Product
25.MS Access
39.stored procedure
Java Database Q&A » mysql » mysql 1 

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

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?

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

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

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

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?

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?

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

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

   stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,

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

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

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

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?

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

I tried to do this tutorial 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

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

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

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

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

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

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

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?

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?

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

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?

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?

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

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?

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

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)

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?

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?

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

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

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

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

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

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?

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

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?

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

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?

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

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

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?

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

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?

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

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

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

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?

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?

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

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

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

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?

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?

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

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

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?

I have a relatively simple object model:

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?

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

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

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

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

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

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

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

public void polacz() {
    try {


65. How do you catch a MySQLIntegrityConstraintViolationException correctly?

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?

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

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

68. Limit MySQL requests

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

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

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

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

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

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?

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

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?

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

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

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

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?

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

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

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?

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

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

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

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

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

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

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

Query ...

88. Java - Communications Link Failure

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 Here ...

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

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

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

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

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

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

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

95. Calling MySql functions remotely fails

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

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

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

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

i am using below code

try {
            conn = ...

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

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 ...  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.