jdbc mysql connection

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
talu
Posts: 9
Joined: Thu May 08, 2003 8:32 pm

jdbc mysql connection

Post by talu » Fri May 09, 2003 4:30 am

hi,
I use an applet as a client to get mysql data in my linux server( apache and mysql in the same pc), in my local lan, the result is fine, but failed in the dial-up method ( outside my local lan), only empty chartpanel shows ..


JAVA shows the warning below:

Cannot connect to MySQL server on 61.xxx.xxx.xxx:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.net.ConnectException)

why? local lan works, but outside local lan fail.......
code -------------------------------------------------------------------------------
public class JChartApplet extends JApplet {

// Constructs the applet

public JChartApplet() {
JDBCXYDataset data = null;

// Connect to the MySql database
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url = "jdbc:mysql://xx.xx.xx.xx/data";
Connection con = DriverManager.getConnection(url, "root", "3687");

data = new JDBCXYDataset(con);
data.executeQuery("Select ptime, last, reg, (reg+ser*2) AS high, (reg-ser*2) AS low from MTXK3Clt0509");
con.close();
}


catch (Exception e) {
System.err.println(e.getMessage());
}

JFreeChart chart1 = ChartFactory.createTimeSeriesChart("MTX Graph", "Time", "MTX", data, true, true, false);

ChartPanel panel1 = new ChartPanel(chart1);
getContentPane().add(panel1);


}
}
------------------------------------------------------------------------------

Bryan.Scott
Posts: 26
Joined: Fri May 09, 2003 4:55 am
Location: Tasmania, Australia
Contact:

RE : jdbc mysql connection

Post by Bryan.Scott » Fri May 09, 2003 4:58 am

Tau

Have you tested your mysql connection from your dialup connection?
That is can you run a simple connection without JFreeChart?
Bryan

talu
Posts: 9
Joined: Thu May 08, 2003 8:32 pm

Application also failed

Post by talu » Sun May 11, 2003 5:04 am

I wrote a Borland8-made jdbe-mysql database application, without JfreeChat, only text query function, I got the same result, the querys work
in my local lan pcs, (I try on 2 pcs with winXP, 1 notebook with win98), but till I change one pc's connection method in dial-up ( also I asked my friend to tried for me, he use Adsl in his company), failed, what on earth the problem is!!! jdbc-mysql applet and application only can work on my local lan, or it is the firwall issue on JAVA made application???

Bryan.Scott
Posts: 26
Joined: Fri May 09, 2003 4:55 am
Location: Tasmania, Australia
Contact:

Post by Bryan.Scott » Mon May 12, 2003 12:18 am

I would suggest that this is not a JFreeChart issue but an issue with your firewall.

A possible solution is if you have a web server available externally is to move to a server based solution and generate a gif/png/whatever at the server.
Bryan

talu
Posts: 9
Joined: Thu May 08, 2003 8:32 pm

talu

Post by talu » Mon May 12, 2003 10:08 pm

Thanks!, it was really the firewall, my iptables block the request from outside of the mysql 3306 port!!!
Thanks you very much!!

Locked