SQL Connecting problems

Hi, and sry for my english

i am having problems to connect to a sql database

the sql DB is from a web host with php and MySql.

I had tried with this driver: com.mysql.jdbc.Driver

and I did this:

Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection conexao = DriverManager.getConnection("jdbc:mysql://"+host+"/"+DBname, user , password);

the host name (host) is this: sql4.prohosts.org

What's wrong?

I have to use other Driver?

Is not possible to connect to this type of sql server?

the hostname is wrong?

please help me ;)

[691 byte] By [rj123a] at [2007-11-27 3:52:42]
# 1
> i am having problemsWhere? You haven't elaborated the problems. Please be specific. What is happening? What are the exact results? (eventual stacktraces included) What did you expect? How did you conclude that it is a problem?
BalusCa at 2007-7-12 8:56:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

Sory for the few info

SqlException

com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.ConnectException

MESSAGE: Connection timed out

STACKTRACE:

java.net.ConnectException: Connection timed out

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(Unknown Source)

at java.net.PlainSocketImpl.connectToAddress(Unknown Source)

(...)

The exception is throwed +/- 40 sec after trying

tkx

rj123a at 2007-7-12 8:56:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
If you'retrying to access remote database form your computer it is possible that you don't hava permission to do that. Sometimes hosting providers only let you access database through such tools as phpMyAdmin
Nemanjaa at 2007-7-12 8:56:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
> The exception is throwed +/- 40 sec after tryingSo it is just an ordinary timeout? And the connection just works before?
BalusCa at 2007-7-12 8:56:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
No, it never have been connected
rj123a at 2007-7-12 8:56:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

Is the mysql server actually up and running and accessible? Is it localhost or an external host? If external, open a command prompt and try to telnet to the hostname and port. Assuming that the server is running at the default port of 3306:

telnet hostname 3306

Do you get connection or not?

BalusCa at 2007-7-12 8:56:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7
It's external. the host name is "sql4.prohosts.org"I did not connect with telnet, I tryed to connect to the ftp: "ftp.prohosts.org" & I could not connect alsosry 4 my bad english :)Waiting for ideasAnd Thanks for the help-
rj123a at 2007-7-12 8:56:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8
Likely there is a firewall or so. Contact the sysadmin of this host and ask if the DB is actually accessible by the Internet.
BalusCa at 2007-7-12 8:56:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...