|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
JSP cannot connect to MySQL Server
Hi,
I am trying to connect to a MYSQL Server (not localhost) and I'm able to connect via MySQL Gui, no problem. But when trying to connect via JSP code, I get the following error message java.sql.SQLException: Server configuration denies access to data source at org.gjt.mm.mysql.MysqlIO.init(Compiled Code) at org.gjt.mm.mysql.Connection.connectionInit(Compiled Code) at org.gjt.mm.mysql.jdbc1.Connection.connectionInit(Compiled Code) at org.gjt.mm.mysql.Driver.connect(Compiled Code) at java.sql.DriverManager.getConnection(Compiled Code) at java.sql.DriverManager.getConnection(Compiled Code) I'm using this code... Class.forName("org.gjt.mm.mysql.Driver").newInstance(); conn = "jdbc:mysql://" + host + "/" + db + "?user=" + user + "&password=" +pass; Connection Conn = DriverManager.getConnection(conn); Could the problem be JDBC related? I would be very glad if someone could help. Thanx in advance otsche |
|
#2
|
|||
|
|||
|
Just a possibility, have you edited your mySQL host tables to allow access from an outside source(not localhost)?
|
|
#3
|
|||
|
|||
|
I am getting exactly the same error and don't know how to fix it, so if you have since rectified it can you post up here??
Thanks Winston |
|
#4
|
|||
|
|||
|
Ok, guys thanks for your help.
it was just as jim_dewit said, the problem was that jdbc/mysql connection (mm.mysql) was not properly configured. suprisingly, in the connection string in the jsp file i also had to use "localhost" as the host and not the ip address of the mysql - server. a sample of the code that works... // database parameters for all .jsp pages String host="localhost"; String user="test"; String pass=""; String db="test"; String conn; Class.forName("org.gjt.mm.mysql.Driver"); conn = "jdbc:mysql://" + host + "/" + db + "?user=" + user + "&password=" + pass; Connection Conn = DriverManager.getConnection(conn); Statement SQLStatement2 = Conn.createStatement(); String Query = "SELECT username,password FROM user WHERE username='"+username+"' AND password='"+password+"'"; ResultSet SQLResult2 = SQLStatement2.executeQuery(Query); while (SQLResult2.next()) { saved_pass = SQLResult2.getString("password"); saved_user = SQLResult2.getString("username"); } SQLResult2.close(); SQLStatement2.close(); Conn.close(); thx for your help so far otsche |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > JSP cannot connect to MySQL Server |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|