【问题标题】:To connect eclipse with database [duplicate]将eclipse与数据库连接[重复]
【发布时间】: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'属性强制初始客户端字符集。”

【问题讨论】:

    标签: java selenium jdbc


    【解决方案1】:

    字符集支持 UTF-8 它对我有用。

    url=jdbc:mysql://localhost:3306/dbname?characterEncoding=utf-8&useConfigs=maxPerformance

    【讨论】:

      猜你喜欢
      • 2016-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-27
      • 1970-01-01
      相关资源
      最近更新 更多