我编写了一个代码来连接 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: Unknown initial character set index '255' received from server. Initial client character set can be forced via the 'characterEncoding' property."
最佳答案
字符集支持 UTF-8 它对我有用。
url=jdbc:mysql://localhost:3306/dbname?characterEncoding=utf-8&useConfigs=maxPerformance
关于java - 连接eclipse和数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58022111/