473,395 Members | 1,454 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Insert to a database using java: problem with greek characters

I'm writing a java programme, which connects to a database in my computer(using jdbc). The database is allowed to use greek characters and I can check that, because when I use a "select" query, the text appears as it should. But when I try to insert new data, instead of greek characters, the result in the database is only some questionmarks. Where is the problem? (I've already defined the collation as utf-8)
Jan 18 '11 #1
2 3791
Dheeraj Joshi
1,123 Expert 1GB
Can you please post the code here. I think it has to do something with the character encoding.

Regards
Dheeraj Joshi
Jan 18 '11 #2
Thank you for the reply.

the part of the code is the following:

try
{
Statement stmt;
ResultSet rs;
Class.forName("com.mysql.jdbc.Driver");
String url ="jdbc:mysql://localhost:3306/users?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true";
Connection con =(Connection) DriverManager.getConnection(url,"root", "");
con.setCharacterEncoding("utf-8");
stmt = (Statement) con.createStatement();
stmt.executeQuery("SET NAMES 'UTF8'");
stmt.executeQuery("SET CHARACTER SET 'UTF8'");
String greekname = "κωνσταντίνα";
stmt.executeUpdate("INSERT INTO user2(userid,username) VALUES ('" + "1" + "','" + greekname +"')");
con.close();
}catch( Exception e ) {System.out.println("problem during the connection with the database!");}



The result in the table user2 is userid:1 and username:???????????
By the way, when i try to insert the same data using php, everything runs ok. However, i need to do this using java.
Jan 18 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Frank Maestas | last post by:
Hello, I database table that I need to add checkbox data (using an array) and standar fields. My standard fields insert just fine, as does my array when trying them alone. Together - doesn't...
4
by: Giannis Vrentzos | last post by:
Hi all, I 'm testing postgres 8.0 beta 1 an i have the following problem. I have a field with value Γιάννης. If i execute the following query it does not returns any rows. select * from test...
2
by: gouletpo | last post by:
Hello everyone and thank you for taking the time to read this. I am fairly new to php and I have a problem I haven't been able to solve. For my web site, I have to send two variables to...
2
by: Hatricks | last post by:
Hi, How can I store & retrieve PDF file in SQL 2005 database using java. Any code will be of great help.
2
by: mannavavp | last post by:
hi friends, please let me know how i can store audio files in database table using java programming?
12
by: Punkis | last post by:
Hi all, I have a problem with my php and mysql project. I use an auctions software, named phpauction for my project. I import into my database with utf8 encodingm and I can see the greek...
1
by: nina15 | last post by:
Hi, I need to confirm the security of my new system so that this needs to be tested for the XSS attacks. Is there a way that the client can access the server Database specially...
0
by: 9664266462 | last post by:
my bean/class page package db; import java.sql.*; public class Topic {
0
by: tangara | last post by:
Hi, I have this form whereby I allow users to checked the number of subjects he is interested. But, I am stuck when I want to parse the parameters into the database. Hope someone can advise...
1
by: Amit yadav2010 | last post by:
I am using java and mysql database and i want to know how to store video in mysql? If anyone know the solution of it. Please let me know it.
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.