Can't make JDBC connection to MySQL (using Java, IntelliJ, and Linux)
From your connection string, this database should be on the local machine. Can you try running this command to ensure the socket is open for connections?
telnet 127.0.0.1 3306
and ensure that it connects? You may not have configured your mysql instance to listen for connections from this machine or on this interface address. If the connection fails, you need to modify your mysql config, for example:
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
Use JDBC/Mysql Connector in intellij idea
You have to add 'mysql:mysql-connector-java:5.1.40' from maven or add it as java library as shown:
Java JDBC connection refused
I have managed to solve the issue on my own. I have changed my connection code to something a little different. And it seems to not error out at all! My new MySQL connection code:
MysqlDataSource ds = new MysqlDataSource();
ds.setDatabaseName("DATABASE");
ds.setUser("USERNAME");
ds.setPassword("USER PASSWORD");
ds.setServerName("localhost");
ds.setPort(3306);
connection = ds.getConnection();
Related Topics
How to View My Realm File in the Realm Browser
How to Troubleshoot "Inconsistency Detected: Dl-Lookup.C: 111" (Java Result 127) Error
Spring JSON Request Getting 406 (Not Acceptable)
Calculating Distance Between Two Points, Using Latitude Longitude
Why Does JPA Have a @Transient Annotation
Setting the Maximum Size of a Jdialog
How to Convert a Java 8 Intstream to a List
Java: How to Call Non Static Method from Main Method
Android Service Needs to Run Always (Never Pause or Stop)
How to View Visual Gc in Visualvm
How to Click an Element in Selenium Webdriver Using JavaScript
Converting a Date String to a Datetime Object Using Joda Time Library
Createprocess Error=206, the Filename or Extension Is Too Long When Running Main() Method
Getting the Filenames of All Files in a Folder
How to Iterate Through the Unicode Codepoints of a Java String