-1

I'm trying to access phpMyAdmin data base from java plug-in project. I have added mysql-connector-java-5.0.8-bin.jar to the external jar files of the project and following is the connection string I use to access the database:

Class.forName ("com.mysql.jdbc.Driver").newInstance ();
String link= "jdbc:odbc:https://just36.justhost.com:2083:databaseName=xxxx";
private static String userName = "xxxx";
private static String password = "xxxx";
Connection conn = DriverManager.getConnection(link, userName, password);

The URL, database name, username and password are correct. But this code gives following error.


java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name too long at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source) at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source) at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source) at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source) at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at vocab.ITSVocabulary.ReadTextInput(ITSVocabulary.java:27)

at vocab.TestMain.main(TestMain.java:23)

Line 27: Connection conn = DriverManager.getConnection(url, userName, password);

I checked the related posts to this problem and set the classpath variable for this JAR file too. Before this, I tried mysql-connector-java-5.1.22.jar, it also didn't work. Do I need to set any class paths, or change any network setting here? I'm really grateful if someone can tell me is there anything wrong with this procedure or what I missed.

Thanks.

Watz
  • 829
  • 8
  • 11
  • 1
    Why it is phpmyadmin? phpmyadmin is nothing, but just a client for mysql, state it like connect java to mysql. User google to search for this, You will find tons of blogs explaining this. – Elbek Sep 30 '12 at 17:50

3 Answers3

3

Why it is phpmyadmin? phpmyadmin is nothing, but just a client for mysql, state the title like connect java to mysql. Use google to search for this, You will find tons of blogs explaining this. this should be fine for you

Community
  • 1
  • 1
Elbek
  • 3,434
  • 6
  • 37
  • 49
1
final String server="localhost/";

final String db_name="db_name";

final String userName="xxxx";

final String password="xxxx";

Connection myConn= DriverManager.getConnection("jdbc:mysql://"+server+db_name,userName,password);
M B
  • 2,326
  • 24
  • 33
NameLess
  • 11
  • 2
0

You are not using a mysql connect string but an odbc one. See http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html

Also it would be a mysql database not phpmyadmin, the latter is a PHP UI for mysql