首页 \ 问答 \ Netbeans和mysql通信(Netbeans and mysql communication)

Netbeans和mysql通信(Netbeans and mysql communication)

我为我们公司创建了一个应用程序。 起初,我试图在我的MySQL-xampp数据库中创建没有密码,它工作正常。 现在我的问题是我在我的数据库上放了一个密码,我的应用程序现在每次登录时都会抛出这个错误:

SQL java.sql.SQLException:对用户'root'@'CITSP-MOB7'的访问被拒绝(使用密码:YES)

连接我的数据库时出错:

无法连接。 无法使用com.mysql.jdbc.Driver建立与jdbc:mysql // localhost:3306 / mydb的连接(对用户'root'@'CITSP-MOB7'(使用密码:YES)拒绝访问)。

这是我的数据库连接代码:

static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://192.168.1.112:3306/citsp";
static final String USER = "root";
static final String PASS = "mypassword";

try{
   Class.forName("com.mysql.jdbc.Driver");
  }catch(ClassNotFoundException ex){
            }
  //STEP 3: Open a connection
  System.out.println("Connecting to database...");
  conn = DriverManager.getConnection(DB_URL,USER,PASS);

  //STEP 4: Execute a query
  System.out.println("Creating statement...");
  stmt = conn.createStatement();

有人可以帮我解决我的连接问题吗? 您的回答将不胜感激。 提前致谢! :)


I've created an application for our company. At first, I've tried to create without password on my database in MySQL-xampp and it works fine. Now my problem is I put a password on my database and my application is now throwing me this error whenever I log in:

SQL java.sql.SQLException: Access denied for user 'root'@'CITSP-MOB7'(using password: YES)

I also get an error connecting my database:

Unable to connect. Cannot establish a connection to jdbc:mysql//localhost:3306/mydb using com.mysql.jdbc.Driver (Access denied for user 'root'@'CITSP-MOB7' (using password: YES)).

Here is my code for database connection:

static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://192.168.1.112:3306/citsp";
static final String USER = "root";
static final String PASS = "mypassword";

try{
   Class.forName("com.mysql.jdbc.Driver");
  }catch(ClassNotFoundException ex){
            }
  //STEP 3: Open a connection
  System.out.println("Connecting to database...");
  conn = DriverManager.getConnection(DB_URL,USER,PASS);

  //STEP 4: Execute a query
  System.out.println("Creating statement...");
  stmt = conn.createStatement();

Can somebody help me to solve my connection problem? Your answer will be appreciated. Thanks in advance! :)


原文:https://stackoverflow.com/questions/29787434
更新时间:2021-08-23 08:08

相关问答

更多
  • 我认为这是URLLoader类中的一个错误。 如果你看到错误信息(至少我得到的那个,你没有粘贴yorrs!)你会看到它: 错误:错误#2029:此URLStream对象没有在flash.net::URLLoader/onComplete()上的flash.net::URLStream/readBytes()打开的流: 这可以让您了解正在发生的事情。 URLLoader类在内部使用URLStream对象,该对象提供对下载数据的低级访问。 该错误消息表明正在URLLoader上调用onComplete处理程序。 ...
  • 我们决定使用tomcat阀门来加载图像,阀门充当从https域加载图像的代理。 We have decided to use tomcat valves for loading the images, valves act as a proxy for loading the images from https domains.
  • 首先,由于load方法是异步的,因此代码中的这三个调用将相继覆盖。 唯一会导致COMPLETE事件被调度的调用将是最后一个调用。 如果要异步加载文件,则需要为每个文件创建一个URLLoader实例。 其次,(更重要的是你的问题) URLLoader类中没有属性允许你访问load()最初被调用的URLRequest 。 一个简单的方法是扩展URLLoader 。 例如,如果你只需要网址: public class MyURLLoader extends URLLoader { private var ...
  • 由于您使用AIR从文件系统加载数据,因此您不必异步执行此操作。 您可以像这样同步加载它: function readTxtList(url:String):Array { var file:File = File.documentsDirectory.resolvePath(url); var fileStream:FileStream = new FileStream(); fileStream.open(file, FileMode.READ); var text:Str ...
  • 我想到的三件事可能导致这种情况: 确保您正在捕获SecurityError.SECURITY_ERROR和IOError.IO_ERROR 。 如果发生错误,则不会引发COMPLETE事件。 如果未将Loader添加到UI树,则无法使用。 如果是这种情况,您应该使用URLLoader 。 如果要使用addEventListener添加事件侦听器,请确保未使用弱引用。 如果你是,并且没有扎根,他们可能被垃圾收集,这将导致你的症状。 Three things come to mind that could ca ...
  • 我之前做过那个..你可以从这里查看我的博客文章,也许它可以帮助你。 我在服务器端使用Java,而不是CF. I did that a some time ago..you can check my blog post from here, maybe it can help you. I was using Java on the server side, not CF.
  • 实际上,在发布此问题后,我认为它可能由URLRequest而不是URLLoader处理。 它是: URLRequest.manageCookies 那么,回答我自己的问题: 是的,它是自动管理它们。 是的,它可以通过适当命名的manageCookies属性进行管理。 Actually, just after posting this question I thought that it may be handled by URLRequest and not URLLoader. It is: URLReq ...
  • 我认为只是你的Main类应该从MovieClip延伸而不是Sprite : public class Main extends MovieClip { // ... } 要在浏览器中调试项目,您可以使用可从此处下载的Flash播放器调试版本。 希望能有所帮助。 I think that simply your Main class should extend from MovieClip and not Sprite : public class Main extends MovieClip ...
  • 是的,URLLoader缓存请求,并且有各种解决方案来中断缓存请求(通常通过在Web请求的末尾添加随机元素)。 您可以在此处查看返回的URLRequest对象的文档 ,以及各种缓存选项。 但是,我建议在收到请求并使用您所在的平台数据库/数据存储模式后在本地保留数据。 然后,在发出请求之前检查Internet:如果可以建立连接,请发出请求以检索和更新本地数据。 如果没有互联网/连接,只需加载您在本地保存的数据。 使用请求的“缓存”版本不是值得信赖的模式。 Yes, the URLLoader caches r ...
  • Flash无法很好地处理HTTP状态代码。 这是一篇博客文章,其中包含Adobe员工的评论,称该问题实际上是插件限制。 Adobe员工指向一个库,用于通过套接字使用AS3执行HTTP请求,但我怀疑这将是非常高效的(与将插件手动请求关闭到浏览器相比)。 我曾经做过的所有项目的标准做法是始终发送200 OK并在消息上添加error密钥。 编辑:也看到这个错误 ,这正是你的问题。 Flash does not handle HTTP status codes very well. Here is a blog p ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。