简体   繁体   English

尝试连接到mysql数据库,出现异常提示“必须在以下位置指定端口号:

[英]Trying to connect to a mysql database, getting exception saying Must specify port number after:

I'm trying to connect to a MySQL database on my website from java. 我正在尝试从Java连接到我网站上的MySQL数据库。

Currently I'm getting a exception that says 目前,我遇到一个例外,说

Must specify port number after:” 必须在以下位置指定端口号:”

I Google stack overflow and found the default MySQL port is 3306. But I can't find any information about how I add it to my url, which now looks like 我Google堆栈溢出,发现默认的MySQL端口是3306。但是我找不到有关如何将其添加到url中的任何信息,现在看起来像

jdbc:mysql://http://www.findmeontheweb.biz/database name"+
     “user=findmeon_bitcoin&password=password

code: 码:

  try {

          // this will load the MySQL driver, each DB has its own driver
          Class.forName("com.mysql.jdbc.Driver");
          // setup the connection with the DB.
          Connection connect = DriverManager.getConnection("jdbc:mysql://http:                  //www.findmeontheweb.biz//findmeon_bitcoin//"+ "user=findmeon_bitcoin&password=oreo8157");


 } catch (Exception e) {
      System.out.println("Exception...." );
    } 

1) Hope the space in your code was only a copy/paste error here 1)希望代码中的空间只是此处的复制/粘贴错误

2) You need to remove the http in the mysql uri 2)您需要删除mysql uri中的http

Connection connect = DriverManager.getConnection("jdbc:mysql://http:                  //www.findmeontheweb.biz//findmeon_bitcoin//"+ "user=findmeon_bitcoin&password=oreo8157");

will be 将会

Connection connect = DriverManager.getConnection("jdbc:mysql://findmeontheweb.biz/findmeon_bitcoin/"+ "user=findmeon_bitcoin&password=oreo8157");

And just in case you are running it on a custom port, you can specify port by 并且以防万一您在自定义端口上运行它,您可以通过以下方式指定端口

Connection connect = DriverManager.getConnection("jdbc:mysql://findmeontheweb.biz:3306/findmeon_bitcoin/"+ "user=findmeon_bitcoin&password=oreo8157");

replace 3306 with your custom port. 用您的自定义端口替换3306。

Also I hope that is not your real username and password! 我也希望这不是您的真实用户名和密码!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试连接到我的sql数据库时出现异常,提示“找不到合适的驱动程序” - Trying to connect to my sql database getting exception saying “no suitable driver found” 尝试连接到 MYSQL 数据库时出现 EJBTransactionRolledbackException - Getting an EJBTransactionRolledbackException when trying to connect to a MYSQL database 试图连接到mysql数据库 - trying to connect to mysql database 尝试将MySQL数据库连接到android时遇到NullPointerException错误 - Getting a NullPointerException error trying to connect a MySQL database to android 尝试使用 jdbc 连接到 mysql 数据库 - Trying to connect to mysql database with jdbc 当我试图从 springboot 中的 Mysql 数据库中获取数据时,我收到以下错误“给定的 id 不能为空” - As iam trying to fetch the data from Mysql Database in springboot iam getting following error of "The given id must not be null" 我正在尝试使用休眠xml映射连接到mysql数据库,但出现此错误 - I am trying to connect to a mysql database with hibernate xml mapping but I am getting this error 尝试连接到 android 上的 mongodb 数据库时出错 - Getting an error trying to connect to mongodb database on android 如果IP正确,但端口或实例错误,MYSQL永远不会停止尝试连接 - MYSQL never stops trying to connect if IP is correct, but port or instance is wrong 尝试连接到MySQL数据库时Java中的NullPointerException - NullPointerException in java while trying to connect to MySQL database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM