473,378 Members | 1,507 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,378 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 3787
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.