database connection

Tags:    java

I’m trying to a get a connection to my database on domain server one.com

Code:

{
try{
Class.forName("com.mysql.jdbc.Driver"); //open driver connection
System.out.println("Driver indlæst");

Connection forb = DriverManager.getConnection
("jdbc:mysql://http://mysql.blabla.com/bla_com ","username","password");
System.out.println("Forbindelse oprettet");

stmt = forb.createStatement();
}catch (Exception e) {System.out.println("no connection to your database");}
}

It doen’t seem to work do you have any ideas of what is wrong

Info:
MySQL:
Host: localhost
Database: bla_com
Brugernavn (User): username
Kodeord (Password): password

PhpMyAdmin:
PhpMyAdmin: http://phpmyadmin.bla.com
Brugernavn (User): bla_com
Kodeord (Password) blabla



2 svar postet i denne tråd vises herunder
1 indlæg har modtaget i alt 4 karma
Sorter efter stemmer Sorter efter dato
You can't connect to the MySQL host from outside. It is only possible to connect to the MySQL server from the webserver. Their firewall is blocking.



There are several things that I would do differently.. first off though, do you have MySQL Connector/J added to your library? without that its a definite no go.

If you do, try this connection code:

Fold kodeboks ind/udKode 




t