Tagged Questions
51
votes
6answers
55k views
186
votes
9answers
88k views
How to get UTF-8 working in Java webapps?
I need to get UTF-8 working in my Java webapp (servlets + JSP, no framework used) to support äöå etc. for regular Finnish text and Cyrillic alphabets like ЦжФ for special cases.
My setup is the ...
29
votes
12answers
79k views
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
I'm working on getting my database to talk to my Java programs. What do I need to get started?
Having already read through (and been thoroughly confused, something that does not happen often) with ...
17
votes
15answers
59k views
Solving a “communications link failure” with JDBC and MySQL
I'm trying to connect to the local MySQL server but I keep getting an error.
Here is the code.
public class Connect {
public static void main(String[] args) {
Connection conn = null;
...
7
votes
2answers
17k views
JDBC MySql Connection Pooling practices
I have a Java-JSF Web Application on GlassFish, in which I want to use connection pooling. Therefore I created an application scoped bean that serves with Connection instances for other beans:
import ...
37
votes
8answers
18k views
LINQ for Java tool [closed]
Would a LINQ for java be a useful tool? I have been working on a tool that will allow a Java object to map to a row in a database.
Would this be useful for Java
programmers?
What features would ...
44
votes
5answers
12k views
How can I protect MySQL username and password from decompiling?
Java .class files can be decompiled fairly easily. How can I protect my database if I have to use the login data in the code?
27
votes
9answers
72k views
MySQL-JDBC: 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:
...
12
votes
4answers
22k views
Multiple queries executed in java in single statement
Hi I was wondering if it is possible to execute something like this using JDBC as it currently provides an exception even though it is possible in the MySQL query browser.
"SELECT FROM * TABLE;INSERT ...
4
votes
3answers
8k views
How I save and retrieve an image on my server in a java webapp
Here with another question on Images ( which seems to be more difficult than I initialy predicted) I'm working on a java Web app with JSF 2.0 ( apache myFaces) and I want this app to be able to upload ...
13
votes
2answers
24k views
Handling MySQL datetimes and timestamps in Java
In a java application what would a good compromise in terms of extracing and inputting date information with a MySQL database using a mix of datetimes and timestamps?
23
votes
9answers
19k views
Running a .sql script using MySQL with JDBC
I am starting to use MySQL with JDBC.
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql:///x", "x", "x");
stmt = conn.createStatement();
stmt.execute( "CREATE ...
4
votes
5answers
12k views
Android JDBC not working: ClassNotFoundException on driver
I'm trying to use JDBC in my Android application to connect to a remote database to do inserts, queries, etc. I have successfully connected and done these things in a different JAVA project. So I ...
14
votes
7answers
48k views
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
I am trying to connect to mysql database using java on windows7. Inspite of adding the complete url of jdbcdriver jar file in CLASSPATH, java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
is ...
5
votes
4answers
12k views
how to get list of Databases “Schema” names of MySql using java JDBC
how to get list of Databases "Schema" names of MySql using java JDBC ?
19
votes
4answers
37k views
Java: Insert multiple rows into MySQL with PreparedStatement
I want to insert multiple rows into a MySQL table at once using Java. The number of rows is dynamic. In the past I was doing...
for (String element : array) {
myStatement.setString(1, ...
32
votes
3answers
109k views
Hibernate: Automatically creating/updating the db tables based on entity classes
I have the following entity class (in Groovy):
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
@Entity
...
10
votes
2answers
31k views
How should I connect to a MySQL data source from Eclipse?
I have an external MySQL server that's set up and working fine. I created a database connection in Eclipse and can view the database in the Data Source Explorer tab.
Now, I have a servlet that needs ...
16
votes
7answers
88k views
Access denied for user 'root'@'localhost' (using password: YES) (Mysql::Error)
I tried to deploy web application on my server and I am getting this mysql database exception
"Access denied for user 'root'@'localhost' (using password: YES) (Mysql::Error)"
tried to access the ...
2
votes
6answers
3k views
Getting last record from mysql
I am using mysql and facing some problem. I want to retrieve last row that is inserted.
<< Below are details >>
Below is how I created table.
create table maxID (myID varchar(4))
I inserted ...
12
votes
5answers
17k views
Streaming large result sets with MySQL
I'm developing a spring application that uses large MySQL tables. When loading large tables, I get an OutOfMemoryException, since the driver tries to load the entire table into application memory.
I ...
11
votes
5answers
23k views
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", ...
16
votes
5answers
36k views
Enum in Hibernate, persisting as an enum
In my MySQL database, there's the column "gender enum('male','female')"
I've created my enum "com.mydomain.myapp.enums.Gender", and in my Person entity I'm defined "Gender gender".
Now I'd want to ...
11
votes
6answers
77k views
No suitable driver found for 'jdbc:mysql://localhost:3306/mysql
I get this error when attempting to connect.
java.sql.SQLException: No suitable driver found for 'jdbc:mysql://localhost:3306/mysql at
java.sql.DriverManager.getConnection(Unknown Source)
at ...
2
votes
1answer
2k views
Stumped SQL Exception for JDBC
I'm trying all I can to get a JDBC to work, the only thing that is stumping me right now is this exception, which I have no idea about:
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have ...
27
votes
8answers
67k views
How to store Java Date to Mysql datetime…?
Can any body tell me how can I store Java Date to Mysql datetime...?
When I am trying to do so...only date is stored and time remain 00:00:00
in Mysql date stores like this...
2009-09-22 00:00:00
...
3
votes
3answers
11k views
Getting java.sql.SQLException: Operation not allowed after ResultSet closed
When I execute the following code, I get an exception. I think it is because I'm preparing in new statement with he same connection object. How should I rewrite this so that I can create a prepared ...
3
votes
4answers
19k views
Android + MySQL using com.mysql.jdbc.Driver
I am writing an Android application that will connect to a MySQL server. For now, I am testing the MySQL server on my computer through XAMPP using http://localhost:3306/. The code below works fine ...
28
votes
10answers
15k views
Is there a more efficient way of making pagination in Hibernate than executing select and count queries?
Usually pagination queries look like this. Is there a better way instead of making two almost equal methods, one of which executing "select *..." and the other one "count *..."?
public ...
13
votes
3answers
15k views
Spring, Hibernate, Blob lazy loading
Dear Sirs,
I need help with lazy blob loading in Hibernate.
I have in my web application these servers and frameworks: MySQL, Tomcat, Spring and Hibernate.
The part of database config.
<bean ...
9
votes
2answers
14k views
JDBC character encoding
I have a Java Web application running on GlassFish 3 and JPA (EclipseLink) on MySQL. The problem I'm facing is that if I'm saving entities to the database with the update() method, String fields lose ...
28
votes
2answers
20k views
Using “like” wildcard in prepared statement
I am using prepared statements to execute mysql database queries. And I want to implement a search functionality based on a keyword of sorts.
For that I need to use LIKE keyword, that much I know. ...
8
votes
4answers
13k views
Java+Tomcat, Dying database connection?
I have a tomcat instance setup but the database connection I have configured in context.xml keeps dying after periods of inactivity.
When I check the logs I get the following error:
...
6
votes
1answer
6k views
Best way to implement Client <-> Server <-> Database architecture in an Android application?
I am making an Android application. Since it is so simple, I first thought I could simply eliminate the need for Java application on the server which acts as a middleware. I tried directly connecting ...
4
votes
5answers
22k views
MySQL Data Truncation Error
I'm working with a fairly simple database, from a Java application. We're trying to insert about 200k of text at a time, using the standard JDBC mysql adapter. We intermittently get a ...
3
votes
3answers
450 views
MySQL select coordinates within range
I've in my database 100 000 addresses (that is records).
Each one of them has its own coordinates (latitude and longitude).
Now, given the geo location of the user (latitude and longitude), I want ...
3
votes
2answers
13k views
How to configure Tomcat 6.0 with MySQL
Could someone provide a few details on how to configure Tomcat to access MySQL?
In which directory within Tomcat do I place mysql-connector-java-5.1.13-bin? Should I place it under Tomcat ...
9
votes
1answer
1k views
Unable to get multiple Table entities through Stored procedure using hibernate
Here is my stored Procedure
Create PROCEDURE [dbo].getUserAndEnum
AS
BEGIN
select * from user_master where id =1
select * from enum_master where id = 1
End
With hibernate i written
Session ...
8
votes
4answers
3k views
Why INSERT IGNORE increments the auto_increment primary key?
I wrote a java program that accesses a MySQL innodb database.
Whenever an INSERT IGNORE statement encounters a duplicate entry the Auto Increment primary key is incremented.
Is this behaviour the ...
0
votes
1answer
129 views
Need suggestions regarding project implementation in Struts and Hibernate [closed]
I am new to Struts and Hibernate. I want to implement a basic web application that uses Struts2 and Hibernate. Now I have my MySQL database ready with all the tables and relationships between them. By ...
5
votes
3answers
6k views
1
vote
4answers
642 views
Should a database connection stay open all the time or only be opened when needed?
I have a bukkit plugin (minecraft) that requires a connection to the database.
Pardon the noob question, but should a database connection stay open all the time, or be opened and closed when needed?
...
22
votes
2answers
14k views
Closing JDBC Connections in Pool
Our standard code section for using JDBC is...
Connection conn = getConnection(...);
Statement stmt = conn.conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE,
...
27
votes
4answers
8k views
Using Solr search index as a database - is this “wrong”?
My team is working with a third party CMS that uses Solr as a search index. I've noticed that it seems like the authors are using Solr as a database of sorts in that each document returned contains ...
23
votes
10answers
32k views
Using Hibernate's ScrollableResults to slowly read 90 million records
I simply need to read each row in a table in my MySQL database using Hibernate and write a file based on it. But there are 90 million rows and they are pretty big. So it seemed like the following ...
16
votes
3answers
25k views
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed
I built an application and deployed locally ... and it was working perfectly. I deployed it on a remote server and started getting the exception mentioned in the subject line. It's not because of any ...
9
votes
7answers
8k views
Optimal number of connections in connection pool
Currently we are using 4 cpu windows box with 8gb RAM with MySQL 5.x installed on same box. We are using Weblogic application server for our application. We are targeting for 200 concurrent users for ...
10
votes
2answers
2k views
Force users to have latest android app version
Is it possible to check on startup of an Android app whether the user has the latest version of it and force him to update if he has not? Or at least checkt whether there is a new version and tell ...
24
votes
2answers
49k views
How to annotate MYSQL autoincrement field with JPA annotations
Straight to the point, problem is saving the object Operator into MySQL DB.
Prior to save, I try to select from this table and it works, so is connection to db.
I think there is some configuration ...
14
votes
4answers
7k views
BLOB vs. VARCHAR for storing arrays in a MySQL table
I've got a design decision to make and am looking for some best practice advice. I have a java program which needs to store a large number (few hundred a day) of floating point arrays in a MySQL ...