【问题标题】:Java MySql connectionJava MySql 连接
【发布时间】:2016-11-29 19:38:41
【问题描述】:

当两者都上传到 c-panel 上的第三方服务器时,Java 项目没有链接到 mysql 数据库。我们收到与连接字符串相对应的空指针异常错误消息(searchdaoimp.java:30)。我们的连接设置如下:

Host= 'ip address of the server' 
Database =database name 
driver=com.mysql.jdbc.Driver 
url=jdbc:mysql://localhost:3306/database name  
User=database username  
Password=database password
MySql connectionPort ='3306'

项目通过以下设置在本地计算机上离线工作:

Driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/muhealdb
User=****
Password=****

【问题讨论】:

  • 请发布报告的异常
  • 添加更多信息。问题不清楚。尝试添加完整的错误、代码示例等
  • 好吧,我假设第三方服务器使用的不是 localhost...

标签: java mysql cpanel


【解决方案1】:

你为什么用url=jdbc:mysql://localhost:3306/database name 不是url="jdbc:mysql://"+Host+":"+connectionPort+"/"+database name吗?

【讨论】:

    猜你喜欢
    • 2016-06-27
    • 1970-01-01
    • 1970-01-01
    • 2011-02-25
    • 2012-10-20
    • 2016-10-23
    • 2014-10-18
    • 2021-06-23
    • 2011-02-17
    相关资源
    最近更新 更多