insert arabic chacters in mysql via java

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:
insert arabic chacters in mysql via java - Java Interview Questions
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
Unable to Insert Arabic words in mysql table
Unable 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 MYSQL
How 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 images into a Mysql database
insert images into a Mysql database  How can I insert images into a Mysql database
insert query in mysql
insert query in mysql  insert query in mysql not working   [INSERT INTO Birthdays(firstname, lastname, birthday, group) VALUES('Sam','Smith','June','Junior
xml to html via java
xml to html via java  how to read xml into html using java code
how to insert and retrieve an image from mysql using java - Java Beginners
how to insert and retrieve an image from mysql using java  how to insert and retrieve an image from mysql using java?  Hi friend, Code to insert image using java : import java.sql.*; import java.io.*; class
Export data in excel sheet via Browse and upload button into mysql database
Export data in excel sheet via Browse and upload button into mysql... the information from it in mysql database's Table Am using struts2,hibernate for making the Java web-application
insert excel sheet into mysql as a table
insert excel sheet into mysql as a table  sir, i want to import an excel sheet into mysql5.0 database as in the table format using tomcat 6.0 by jsp
Accessing database with JDBC via Java
Accessing 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
please let me get code how to insert a data to mysql using setter and getter method by using java
please let me get code how to insert a data to mysql using setter and getter method by using java  please let me get code how to insert a data to mysql using setter and getter method by using java pelease let me have the code
please let me get code how to insert a data to mysql using setter and getter method by using java
please let me get code how to insert a data to mysql using setter and getter method by using java  please let me get code how to insert a data to mysql using setter and getter method by using java pelease let me have the code
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
how to insert excel file into mysql datbase in servlet
how to insert excel file into mysql datbase in servlet  emphashow to insert excel file into mysql datbase inservletized text
example of before insert trigger in mysql
example 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
how insert multiple images in mysql database with use of struts 1.3.8 or java method, with single bean,or using array
how insert multiple images in mysql database with use of struts 1.3.8 or java method, with single bean,or using array  i am using netbeans 7.0 ,with struts 1.3.8 and i want to insert multiple images in mysql database ,with use
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
how to insert the selected item of combobox in mysql - XML
how to insert the selected item of combobox in mysql  hi, i have to insert the selected item from combobox into MYSQL database.pls provide... of combobox in mxml.how to insert selecteditem in database. pls suggest me i have
A Java Program That Prints Out Result Via Printer
A 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-Servlet
JSP 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 name city and upload image in database using mysql and jsp
insert name city and upload image in database using mysql and jsp   insert name city and upload image in database using mysql and jsp
insert data into mysql databse using swing
insert 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.
Uploading Excel sheet record in JSP to insert data in MySql
Uploading Excel sheet record in JSP to insert data in MySql  Need Help how to upload Excel (.xls) file and insert data in Mysql using JSP it wil be wonder for me if any help me
Query to insert values in the empty fields in the last row of a table in Mysql database?
Query to insert values in the empty fields in the last row of a table in Mysql database?  I have some fields filled and some fields empty in the last row of my MYSQL database. Now I want to fill up those empty fields in the last
insert name city image in database using mysql and jsp
insert name city image in database using mysql and jsp  how to insert name ,city and image in database in mysql and jsp   Here is an example in jsp that insert name, city and image to database. <%@ page import
insert multiple selection - Java
insert multiple selection - Java  how to insert multiple selection values from html into database using servlets
Insert a row in 'Mysql' table using JSP Code
Insert 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
How to insert image in MySQL database using sql query?
Insert image in MySQL database using sql query  ... in MySQL database and then used the query to insert the data... tutorial of "How to insert image in MySQL database using sql query?": So
insert
insert  insert data in database from servlet through JDBC   Ho Friend, Please visit the following:ADS_TO_REPLACE_1 Insert data into database Thanks
fetch and insert multiple rows into mysql database using jsp servlet
fetch and insert multiple rows into mysql database using jsp servlet  ... jsp form and want inserting it into my mysql database table. but i am having a problem to insert multiple rows into database using a single insert query
How to insert and retreive an image in mysql database using spring mvc framework???
How to insert and retreive an image in mysql database using spring mvc framework???  I ve solved this problem based on the Product Search Application. Those who need this concept and code segment kindly copy it. Thanks and All
Insert Blob(Image) in Mysql table using JSP
Insert 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
ModuleNotFoundError: No module named 'arabic-pronounce'
ModuleNotFoundError: No module named 'arabic-pronounce'  Hi, My... named 'arabic-pronounce' How to remove the ModuleNotFoundError: No module named 'arabic-pronounce' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'arabic-pronunciation'
ModuleNotFoundError: No module named 'arabic-pronunciation'  Hi...: No module named 'arabic-pronunciation' How to remove the ModuleNotFoundError: No module named 'arabic-pronunciation' error? Thanks   Hi
ModuleNotFoundError: No module named 'arabic-pronunciation'
ModuleNotFoundError: No module named 'arabic-pronunciation'  Hi...: No module named 'arabic-pronunciation' How to remove the ModuleNotFoundError: No module named 'arabic-pronunciation' error? Thanks   Hi
ModuleNotFoundError: No module named 'arabic-reshaper'
ModuleNotFoundError: No module named 'arabic-reshaper'  Hi, My... named 'arabic-reshaper' How to remove the ModuleNotFoundError: No module named 'arabic-reshaper' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'arabic-reshaper'
ModuleNotFoundError: No module named 'arabic-reshaper'  Hi, My... named 'arabic-reshaper' How to remove the ModuleNotFoundError: No module named 'arabic-reshaper' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'arabic-pronounce'
ModuleNotFoundError: No module named 'arabic-pronounce'  Hi, My... named 'arabic-pronounce' How to remove the ModuleNotFoundError: No module named 'arabic-pronounce' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'arabic-pronunciation'
ModuleNotFoundError: No module named 'arabic-pronunciation'  Hi...: No module named 'arabic-pronunciation' How to remove the ModuleNotFoundError: No module named 'arabic-pronunciation' error? Thanks   Hi
ModuleNotFoundError: No module named 'arabic-reshaper'
ModuleNotFoundError: No module named 'arabic-reshaper'  Hi, My... named 'arabic-reshaper' How to remove the ModuleNotFoundError: No module named 'arabic-reshaper' error? Thanks   Hi, In your python
send sms from pc to mobile via gsm modem in java
send 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 Image into Mysql Database through Simple Java Code
Insert Image into Mysql Database through Simple Java Code... simple java code that how save image into mysql database. Before running...' in database 'mahendra'. Before running this java code you need mysql connector
send sms from pc to mobile via gsm modem connected to pc in java
send sms from pc to mobile via gsm modem connected to pc in java  pls send me the code to send sms from pc to mobile via GSM modem programmed in JAVA
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 database
Insert 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");  

Ads