insert arabic chacters in mysql via java
Dear,
I have I java rpogram that I want to insert arabic letters in mysql.
Do you have any idea about the configuration of mysql that accepts arabic charcters.
I will send you the code:
package DBFin;
import java.sql.*;
import java.io.*;
import java.lang.Class;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;
public class in_concept
{
static public final String driver = "com.mysql.jdbc.Driver";
static public final String connection =
"jdbc:mysql://localhost:3306/test?user=root&password=1qaz0okm";
public static void main(String args[])
{
try
{
Class.forName(driver);
Connection con = DriverManager.getConnection(connection);
System.out.println("Jdbc Mysql Connection Url :");
System.out.println(connection);
System.out.println("Fathi");
ResultSet rs;
Statement stmt=con.createStatement(); //create a Statement object
try
{
String query = "select * from Mydocument";
//Statement s = connection.createStatement();
stmt.executeQuery (query);
rs = stmt.getResultSet();
while (rs.next ())
{
//Add records into data list
System.out.println(rs.getString(1));
}
rs.close ();
stmt.close ();
}
catch(Exception e)
{
System.out.println("Exception is ;"+e);
}
con.close();
if (!con.isClosed())
{ con.close(); }
} catch (Exception e) {
e.printStackTrace();
}
try
{
Class.forName(driver);
Connection con = DriverManager.getConnection(connection);
//Record data in database
int ID = 95;
//this characters are arabic charcters
String DESC = "هندسة البرمجيات";
String Date_creation = "2010-04-26";
// declare object of Statement interface that uses for executing sql statements.
PreparedStatement ps = null;
int updateQuery = 0;
String query = "INSERT INTO mydocument VALUES (?, ?, ?)";
ps = con.prepareStatement(query);
ps.setInt(1, ID);
ps.setString(2, DESC);
ps.setString(3, Date_creation);
updateQuery = ps.executeUpdate();
if (updateQuery != 0)
System.out.println("Data is inserted successfully in database");
// close all the connections.
ps.close();
con.close();
}
catch (Exception ex)
{
System.out.println("Unable to connect to batabase.");
}
}
}
View Answers
June 23, 2011 at 1:15 AM
here is the solution , it's helpful
it's works with me
Related Tutorials/Questions & Answers:
Unable to Insert Arabic words in mysql tableUnable to
Insert Arabic words in
mysql table I have I
java program that I want to
insert arabic letters in
mysql.
Do you have any idea about the configuration of
mysql that accepts
arabic charcters.
in jsp use
Advertisements
How to load Arabic csv to MYSQLHow to load
Arabic csv to MYSQL I tried the following
set session collation_database=utf8_general_ci;
set session character_set_database=utf8... BY ','
LINES TERMINATED BY '\r\n' ;
but the
arabic columns still appears
Mysql Insert
Mysql Insert
Mysql Insert is used to
insert the records or rows to the table.
Understand with ExampleADS_TO_REPLACE_1
The Tutorial illustrate an example from '
Mysql Insert insert query in mysqlinsert query in mysql
insert query in
mysql not working
[
INSERT INTO Birthdays(firstname, lastname, birthday, group) VALUES('Sam','Smith','June','Junior
Accessing database with JDBC via JavaAccessing database with JDBC
via Java How to access a database with JDBC
via Java application?
Accessing database with JDBC through
Java
JDBC Example to access Database
import java.sql.*;
public class JdbcConnect
Mysql Multiple Date Insert Mysql Multiple Date
Insert
Mysql Multiple Column
Insert is used to add or
insert...
The Section of Tutorial illustrate an example from '
Mysql Multiple Column
Insert How to insert data into MySQL Table?How to
insert data into
MySQL Table? Hi,
How to
insert the data into
MySQL Database? Please explain me with the examples and videos thanks.
Thanks
Hi,
The
insert into query is used to
insert the data into
MySQL Mysql Multiple Date Insert Mysql Multiple Date
Insert
Mysql Multiple Column
Insert is used to add or
insert... of Tutorial illustrate an example from '
Mysql Multiple Column
Insert example of before insert trigger in mysqlexample of before
insert trigger in mysql Hi,
How to create a simple before
insert trigger in
MySQL?
Thanks
Hi,
The before
insert... in
MySQL database server and executed on the server itself. So, its very fast.
First
MySQL PHP Insert MySQL PHP
Insert
Mysql PHP
Insert is used to execute the
Mysql function ( )
insert...,'
Q','26000');
Query OK, 1 row affected (0.01 sec)
mysql>
insert Mysql Trigger After Insert Mysql Trigger After
Insert
Mysql Trigger After
Insert fired the trigger after you..._TO_REPLACE_1
The Tutorial illustrate an example from
Mysql Trigger After
Insert A Java Program That Prints Out Result Via PrinterA
Java Program That Prints Out Result
Via Printer A
Java Program That Prints Out Result Through Printer Depending upon paper size , and print the calculated result on printer and save result as text file
JSP Radio Button MySQL insert - JSP-ServletJSP Radio Button
MySQL insert Hi,
I have an HTML form which has... with select lists. I have created a servlet to connect to
MySQL database... with the code to store radio button data and checkbox data to
MySQL table. For example
insert data into mysql databse using swinginsert data into
mysql databse using swing
Blockquote
hi,
here is my code,
i want code for store data into
mysql database when click on submit button from access data from this form,
please provide code,
import java.awt.
Insert a row in 'Mysql' table using JSP CodeInsert a row in '
Mysql' table using JSP Code
In this section, we will discuss about how to
insert data in
Mysql database
using JSP code.
Query...
between your Tomcat server &
Mysql database Table.
Code to
insert row in
Mysql insertinsert
insert data in database from servlet through JDBC
Ho Friend,
Please visit the following:ADS_TO_REPLACE_1
Insert data into database
Thanks
Insert Blob(Image) in Mysql table using JSPInsert Blob(Image) in
Mysql table using JSP
In this Section, we will
insert blob data(image) in
Mysql database table
using JSP code.
A Blob stores a binary...;
String url="jdbc:
mysql://192.168.10.13:3306/ankdb";
try
send sms from pc to mobile via gsm modem in javasend sms from pc to mobile
via gsm modem in java pls send me the code to send sms from pc to mobile
via GSM modem
programmed in
JAVA........
can u pls help me to retrieve message from mobile to
java program...
import
Insert Mysql Blob data Insert Mysql Blob data
In this section, we will discuss about how to
insert a blob data into a
database table. A Blob stores a binary large...
value. Blob was added to
java in jdk1.2 .
The Method defined in "
Insert current date into MYSQL databaseInsert current date into
MYSQL database
In this tutorial, you will learn how to
insert current date into database.
In most of the applications, there is a need to
insert date or time to
database.
Mysql provides several datatypes
Insert into table using Java Swing
INSERTION IN TABLE USING SWING
In this section, We will
insert rows into "Mysql" database using "Swing".
What is Swing?
Swing...:
mysql://192.168.10.13:3306/ankdb","root","root");