• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

connecting to online SQL DB

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi people,

I have a .exe java application which require me to connect to online sql database. The database only have php scripting, no JDBC. Now my question is how am i going to connect? I read up and I need JApplet to be the bridge is this right?
Is there any help?

Thank you for reading, hope to see your reply soon =)
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

swee dx wrote:I have a .exe java application...


What do you mean with this; do you have a Java application which is compiled to a native Windows executable (*.exe file)?

swee dx wrote:The database only have php scripting, no JDBC.


You need a JDBC driver, which is normally only a JAR file that you have to put in your classpath. What kind of database is it (MySQL, Oracle, PostgreSQL, Microsoft SQL Server, ...)? For almost all kinds of databases there is a JDBC driver available, and you can usually find it on the website of the manufacturer of the database.

swee dx wrote:I read up and I need JApplet to be the bridge is this right?


A Java applet (that's what I guess you mean by "JApplet") is in itself not something that's going to help you connect to the database. You might need to make an applet, but maybe not, it depends on other things, like whether the database allows access from remote systems or not. An applet runs on the user's computer, inside the web browser. If the database can only be accessed from the server itself, you'll need Java code that runs on the server (for example, a servlet that you'd run in a Java EE web container or app server), not an applet that runs on the client.
 
Marshal
Posts: 80874
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I am afraid we probably can't answer without knowing more details. But this sounds too difficult a question for "beginning Java", so I shall move it. Not sure where; let's try our databases forum.
 
swee Ryan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What do you mean with this; do you have a Java application which is compiled to a native Windows executable (*.exe file)?


No, sorry my fault it is a Executable JAR file

You need a JDBC driver, which is normally only a JAR file that you have to put in your classpath. What kind of database is it (MySQL, Oracle, PostgreSQL, Microsoft SQL Server, ...)? For almost all kinds of databases there is a JDBC driver available, and you can usually find it on the website of the manufacturer of the database.


Now i am using http://members.000webhost.com/login.php MySQL. They didn't provide JDBC driver for some unknown reason.

A Java applet (that's what I guess you mean by "JApplet") is in itself not something that's going to help you connect to the database. You might need to make an applet, but maybe not, it depends on other things, like whether the database allows access from remote systems or not. An applet runs on the user's computer, inside the web browser. If the database can only be accessed from the server itself, you'll need Java code that runs on the server (for example, a servlet that you'd run in a Java EE web container or app server), not an applet that runs on the client.



Yes, the database allows remote access. Meaning I have to upload the whole project into the server?? Im lost here. Sorry I'm new to web hosting.

Thanks to Campbell Ritchie, ya I'm not sure where i should post. Thanks
 
Campbell Ritchie
Marshal
Posts: 80874
506
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Surely MySQL provide a JDBC driver? Like Java™, MySQL is provided by Oracle.
 
swee Ryan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
=( no unfortunately, campbell. I went to a couple online MySQL database hosting service they mention JDBC and executable JAR file program are not able to connect with them, even with paid hosting.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Having applets connect via JDBC from the open internet is not a good idea for security reasons; I can understand hosting companies preventing that.

A server-side HTTP proxy -like Jesper mentioned- (in your case implemented in PHP) would be a way around that.
 
swee Ryan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ulf for reply, but i serious have no idea and i google the problem. How can Java integrate/communicate with php?? Please help.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Via HTTP. The applet would send HTTP requests to the PHP page that contain all the parameters the PHP page would need to make a DB call. The PHP page would then read the DB's response, and reformat them in some way that's suitable for the applet to consume (maybe JSON or XML).

Here's code that does part of what the applet would do: http://www.exampledepot.com/egs/java.net/ReadFromURL.html
 
swee Ryan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks ulf.
can it implement in Java file not Java Applet because i try to link my java application to Java Applet but failed.

so the php just have the functions to retrieve data right? my php is upload to the server. I really have been trying to solve and learn php.

Thanks for all the help
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

can it implement in Java file not Java Applet because i try to link my java application to Java Applet but failed.


I'm not sure what you're asking here. A "Java application" is generally understood to be a desktop application - that's different from an applet. If you want to run your code as an applet, then you'll have to rewrite it to *be* an applet.

But it's perfectly possible for the code I pointed to to be part of a desktop application. Depends on whether you want a desktop app or an applet; an applet is certainly not required to connect to a server.
 
swee Ryan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much Ulf

Sorry about my terms. Yes mine is a Java application, desktop application. I try to program my Java application to call/execute the java applet but fail.

It can't be convert to java applet because of file chooser not available in java applet [security reason] and java.awt.geom* which allow user to draw different shapes.

 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Yes mine is a Java application, desktop application. I try to program my Java application to call/execute the java applet but fail.


I don't know how you tried to "call/execute" an applet from a desktop application (something that seems to make little sense), but as I said, there's no need to use an applet as far as I can tell from your previous posts. Maybe you can elaborate on why you think you need to use one?
 
swee Ryan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for your help and patient.

As i Google, i bookmark a couple of them showing how Java applet integrate with java applet. I try google for java application to integrate with php also but it is not i wanted. thus i thought maybe java application link to java applet so that it can link with my online sql database.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

how Java applet integrate with java applet.


Sorry, I have idea what you mean by "integrate an applet with an applet".

java application to integrate with php also but it is not i wanted.


I wouldn't call an HTTP call "integration"; it sounds like you may have found something unrelated.

thus i thought maybe java application link to java applet so that it can link with my online sql database.


Again: A Java desktop application has no problems making HTTP calls to a web server, whether implemented in PHP or some other technology. An applet is not required for this. Have you tried the code I linked to earlier? If not, that would be a good start.
reply
    Bookmark Topic Watch Topic
  • New Topic