0

I have a Raspberry Pi running a mysql server which is working fine and I can connect to it with it's ip address (192.168.1.90) (local, for now), and see the databases and tables etc which are stored on it. I have it set up with phpmyadmin where I have created a database called "world" which has a number of tables.

I've tried to connect to it with java with the following code:

Connection connection = DriverManager.getConnection("jdbc:mysql://192.168.1.90/world", "root", "mypass");

However this gives me an error message:

 java.sql.SQLException: No suitable driver

I know that the username and password are both correct since I can use them and successfully when I execute the command:

mysql -u root -p

I use my android phone for developing but since it's connected to the wifi that shouldn't be a problem (I can reach 192.168.1.90 fine).

I've been out of the game for a couple of weeks and it feels like there is something I'm missing, but I don't see it.

EDIT: I did not compile the .jar for the mysql connector in the gradle file. However, I now get another error which says:

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.

Thanks for taking the time to read about my problem. All help is appreciated!

boking
  • 145
  • 1
  • 12
  • There are numerous questions on this topic [like this](http://stackoverflow.com/questions/22384710/java-sql-sqlexception-no-suitable-driver-found-for-jdbcmysql-localhost3306) or [this](http://stackoverflow.com/questions/17507449/java-sql-sqlexception-no-suitable-driver-found) . Did you try all of them first, before asking? (there are 2-3 more, I copied just a few). – Vucko Jun 28 '16 at 21:11
  • I forgot that I had to add the jar file to the lib folder and compile that in the gradle file... However, now I get an error "com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server." Do I need to have the .jar on the pi somehow? – boking Jun 28 '16 at 21:40
  • Dunno, keep googling :D – Vucko Jun 28 '16 at 21:43

0 Answers0