【发布时间】:2020-01-21 03:26:14
【问题描述】:
我已经编写了一个代码来连接 eclipse 和 sql server 来自动化数据库。
我曾尝试在各种网站的帮助下编写代码,但徒劳无功。
这是我写的代码:
import java.sql.*;
class mysqlcon{
@SuppressWarnings("unused")
public static void main(String args[])
{
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
String host= "localhost";
String user = "shamima";
String passwd = "Welcome@123";
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(
"jdbc:mysql://127.0.0.1:3306/eatngo",user,passwd);
stmt=con.createStatement();
rs=stmt.executeQuery("select * from
ezee_posguest_master");
while(rs.next())
System.out.println("connection
established");
con.close();
}catch(Exception e)
{
System.out.println(e);
}
}
我只是想将我的 Eclipse 与数据库连接起来。
但我得到一个错误:
“java.sql.SQLException:从服务器接收到未知的初始字符集索引'255'。可以通过'characterEncoding'属性强制初始客户端字符集。”
【问题讨论】: