我正在使用带有MY SQL Server 5.0的Eclipse。
使用JFrame,我将泰米尔语单词插入文本字段。但是,MY SQL控制台显示问号而不是泰米尔语单词。我还在文本字段中看到了问号,但是我可以使用Alt + Shift键在泰米尔语中键入。
(泰米尔语是带有特殊字符的印度语言)
如何正确切换到Unicode?
最佳答案
enter code here
尝试
{
尝试
{
Class.forName ("com.mysql.jdbc.Driver");
try
{
java.sql.Connection conn =
DriverManager.getConnection(“ jdbc:mysql:// localhost:3306 / mydbase?
useUnicode = true&characterEncoding = utf-8“,” root“,” ALPHAS“);
String sql = "insert into morph values(?,?,?)";
String sql1 = "insert into word values(?)";
String sql2 = "insert into stems values(?)";
String sql3 = "insert into suffixs values(?)";
java.sql.PreparedStatement psmt = conn.prepareStatement(sql);
java.sql.PreparedStatement psmt1 = conn.prepareStatement(sql1);
java.sql.PreparedStatement psmt2 = conn.prepareStatement(sql2);
java.sql.PreparedStatement psmt3 = conn.prepareStatement(sql3);
String s= jTextField1.getText() ;
String sq = "select*from word";
String sqlA = "select Word from morph where Word
=“ +”'“ + jTextField1.getText()+”'“;
try
{
java.sql.Statement stmtB = conn.createStatement();
java.sql.ResultSet rsq = stmtB.executeQuery(sqlA);
while(rsq.next())
{
String sA = jTextField3.getText() ;
String ds = "WordExists";
if (s== sA)
{
jTextField3.setText(rsq.getString("Word"));
jTextField1.setText(rsq.getString("ds"));
}
}
}
catch (SQLException e )
{
e.printStackTrace();
}
String sA = jTextField3.getText() ;
char [] ch = s.toCharArray();
int y = s.length();
int k = 1;
对于(int m = y-1; m> = 0; m--)
{
字符串pl1 =新的String(ch,0,m);
if(pl1.length()>=2)
{
char[] dh = new char[y];
int c=y-1;
int g = y-1;
for (int j=c; j>=0; j--)
{
if(m>=2)
{
dh[g] = ch[j];
String pl = new String(ch,0,m);
String mpm = new String(dh,0,y);
--m;
// System.out.println(""+pl+"/"+mpm.trim()+"");
// System.out.println(""+pl+"/"+mpm.trim()+"");
g--;
k++;
if(k==y-1)
{
System.out.println(""+pl+"/"+mpm.trim()+"");
psmt.setString(1,s);
psmt.setString(2,pl);
psmt.setString(3,mpm.trim()+"");
psmt1.setString(1,s);
psmt2.setString(1,pl);
psmt3.setString(1,mpm.trim()+"");
psmt.executeUpdate();
psmt1.executeUpdate();
psmt2.executeUpdate();
psmt3.executeUpdate();
}
}
}
}
}
}
catch(Exception E)
{
E.printStackTrace();
}
}
catch(Exception E)
{
E.printStackTrace();
}
}
catch(Exception E)
{
E.printStackTrace();
}