views:

246

answers:

5

I'm currently using a hosting service that offers users access to MySQL databases, but does not offer a Tomcat server or any other way to perform server side processing. So a three tier design is out.

Being a novice in Java and Javascript I was planning on using them on this project to gain more experience. I know nothing about PHP, which I've heard may be the solution to my problem. Does anyone know a way to use Java/Javascript to gain access to a MySQL database from the browser client?

Thanks, Mark

+1  A: 

Javascript runs in a sandbox, and can not do things like opening files, connecting to a MySQL database and so on. Despite the similar name, Java and Javascript have nothing in common.

PHP and Java are both server side systems, and they are both able to connect to MySQL databases.

August Lilleaas
A: 

Your MySQL Installation should have a hostname and port associated with it. You can connect to that host/port via a different program(running elsewhere since you mentioned it is not available here). You can probably write your scripts on some place where you are allowed to do so and access the database via a network connection.

Thiyagaraj
True, though it's pretty common to have firewalls around the database server so that it can't be accessed from outside the building. Another thing to check on.
Jay
+1  A: 

PHP is indeed server-side, but many ISPs that don't provide JSP, ASP, etc, nevertheless do provide PHP. So that may actually be available to you. I guess the short answer is: Find out exactly what tools are available. If your ISP does not provide anything that meets your needs, find another ISP. I'm running several JSP/servlet sites on an ISP that charges me, I think it's $8 a month.

Jay
A: 

Java can access MySQL over TCP ... no browser API for JavaScript allows TCP, so JavaScript is not an option, except serverside JavaScript ... if you really want to have a direct connection, Java will probably be your choice ... you can create a Java applet, which will connect to the remote MySQL daemon, using ... you may have to sign it though, in case the default sandbox does not allow this kind of communication ...

alternatively, you could use FlashPlayer 9+, in theory, but you'd have to implement the whole protocol in ActionScript 3 or haXe, so that's not so much of an option I guess ...

however, the 3 tier design you don't want, is really the best way to go, due to several reasons:

  • flexibility: if you introduce an extra layer between the client and the database, this gives you more power for later modifications and decouples client and DB ...
  • control: it is much easier to control/restrict access to the database
  • security: typically, you'd configure your MySQL DB, so that it will only accept connections from very few hosts, usually only localhost, and maybe one external server ... this way, the security of your DB practically is the security of the external server, since probably noone else even knows the DB ... I wouldn't say it's easy to secure a server ... but it's more secure than if you have numerous public accounts, that may access the DB from any host, over unsecure connections ...

greetz

back2dos

back2dos
A: 

So your hosting company provides a MySQL database, but no runtime to programmatically access/modify it?! That is borderline worthless. Are you sure you know what you're talking about?

Josh Stodola
Not very diplomatically said, but essentially correct. If the ISP provides MySQL, they almost surely provide some way to create pages to access it. You just need to find out what. It's possible that the ISP is nuts and provides worthless tools, but probably not.
Jay