亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何將我的遠程 MySQL 數據庫與 jdbc 連接?錯誤是什么意思?

如何將我的遠程 MySQL 數據庫與 jdbc 連接?錯誤是什么意思?

森林海 2022-09-28 16:19:55
顯示錯誤:-Tue Apr 09 14:34:46 IST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.java.sql.SQLException: Access denied for user 'sql12287303'@'localhost' (using password: YES)我成功地在本地計算機中使用了數據庫,但我無法連接到我的遠程mysql服務器。public class JDBCDemo {    public static void main(String[] args) {        String TableName;        // TODO Auto-generated method stub        try{            String url="jdbc:mysql://localhost:3306/sql12287303";           //3306/db1?autoReconnect=true&useSSL=false";            String username="sql12287303";            String password="54hBDtsfPg";            Class.forName("com.mysql.jdbc.Driver").newInstance();            Connection con = DriverManager.getConnection(url, username, password);            System.out.println ("Database connection established");            System.out.println(con);            Statement smt = con.createStatement();            smt.execute("create database db1");            smt.execute("use db1");            smt.execute("create table flames(id Integer primary key,fname varchar(20),sname varchar(20)");            smt.execute("show tables");            ResultSet rs = smt.getResultSet();            while(rs.next()){                TableName = rs.getString(1);                System.out.println("Table Name:"+TableName);            }        }catch(Exception e){System.out.println(e);}     }}表名:火焰
查看完整描述

1 回答

?
藍山帝景

TA貢獻1843條經驗 獲得超7個贊

我想一個暗示是不夠的。

此代碼指示 JDBC 驅動程序連接到名為 上的數據庫:sql12287303localhost

String url="jdbc:mysql://localhost:3306/sql12287303";

您報告的錯誤表明您實際上正在連接到 ,但其用戶在運行該位置的數據庫服務器上是未知的。localhost

如果要連接到遠程數據庫,則需要更改 URL:

String url="jdbc:mysql://sql12.freemysqlhosting.net:3306/sql12287303";


查看完整回答
反對 回復 2022-09-28
  • 1 回答
  • 0 關注
  • 61 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號