Results 1 to 10 of 10
  1. #1
    Join Date
    Jan 2003
    Posts
    93

    Java / Php & MySQL?

    Hi,

    I want to have an application with a web interface and a gui, both running from the same database. Is java compatable with a mysql database if so how?

    Thanks.
    Please visit my auto an up and coming community for all car discussion.

  2. #2
    Join Date
    Dec 2004
    Location
    Washington, DC
    Posts
    787
    Yes, I have a basic foundation in Java; you can via importing the appropriate things (i.e. import java.sql.Connection).

    Google is your friend: http://www.google.com/search?q=Java+MySQL

  3. #3
    Join Date
    Oct 2006
    Posts
    44
    Java uses the Java Database Connectivity (JDBC) API as its primary method for connecting to daabases. And yes, the JDBC will let you connect to MySQL, or most any other SQL based database system.
    Andrew
    Spry VPS Hosting cPanel VPS, Plesk VPS, Webmin VPS, Shared, Domain Registration, Dedicated and Colo
    VPSLink Cheap VPS accounts CentOS, Fedora 4/5/6, RHEL, Gentoo, Debian, Ubuntu -- Dapper/Edgy, Slackware, OpenSUSE, LAMP + Ruby pre-installed available

  4. #4
    Join Date
    Jul 2005
    Location
    Atlanta, GA
    Posts
    13
    Quote Originally Posted by PHaWKs
    Hi,

    I want to have an application with a web interface and a gui, both running from the same database. Is java compatable with a mysql database if so how?

    Thanks.
    You can use Java to talk directly to the database with jdbc. But, you might not actually want to do this.

    The first question is, who has access to the GUI? If this is all inside your company on an intranet, having java talk directly to the database is probably okay. But if the GUI is going to be available to the public, you'd have to open your database to the world, and that could be dangerous. (Also, many people would have firewall issues trying to talk to the MySQL port)

    The other problem is having duplicate code between the php and java versions.

    You might find that a better approach is to write the web app, and then create a SOAP or XML-RPC API so that the web server handles all the logic, and the GUI clients can just make it look nice.

    The other thing to think about is: would it make more sense to write both sides in Java? Even with a web service, you might be reusing various classes in the two versions, and if they're both written in java you can reuse the code directly.

    <<Signature to be setup in your profile>>
    Last edited by anon-e-mouse; 10-25-2006 at 09:59 PM.

  5. #5
    Join Date
    Aug 2001
    Posts
    5,068
    As already mentioned you need MySQL's Connector library.
    Sitemeer.com - Is your site up?
    Multi-Location Service Availability Check ● yes, we do HTTPS & IDN!


  6. #6
    I am programming a webapp in Java as well. One of the hottest technologies now are Object Relation Mappers (ORM). Basically you can avoid having to code SQL and instead work with objects directly. They get populated with data from the database automatically, and any changes you make to the object will propagate back in. You can find more information by looking it up on wikipedia or google. The most popular ORM for java is probably Hibernate. It can save you a lot of time and you don't need a DBA right away. Good luck!

  7. #7
    Join Date
    Nov 2001
    Location
    Vancouver
    Posts
    2,416
    Mr. Wallace's comments hit the right chords. If your application - GUI clients and web "clients" - are all on a network that you or your client controls (private or proven to be secure) then exposing SQL across the wire to GUI clients (via whatever DB glue you choose to use) is a timed honoured technique.

    If on the other hand you need to support GUI clients outside of a controlled network, you might want to consider XMLRPC, SOAP, or perhaps preferably, REST for opening up your core API to remote GUI clients. Sure you can open up a public port to a database server, but you probably really don't want to do that.

    I like Michal's thoughts on writing both aspects of the application in one technology. Here's where PHP is less useful than say Java or Python. Either Java or Python can be used to create cross-platform GUI applications. The two take different approaches to this end.

    You'd save a lot of time, and future maintenance, by consolidating your core application libraries and APIs on one language platform. You'll write the core logic only once (and thus have only one "core" to maintain) and then two clients - one gui, one web.
    “Even those who arrange and design shrubberies are under
    considerable economic stress at this period in history.”

  8. #8
    If it's GUI for simple application, you can use XML for database exchange. I was working for similar project, where had java client for managing store. Now thinking about similar on .NET.

    BTW, there are ORM for php too.
    2mwatkins: I think, he has written php/mysql application, and need a gui manager solution on java
    HostNodeList Web Host Directory, DEV.INTOEX.COM - products for online business

    Experienced web-developer | PHP | Smarty | Zend | Databases | Graphic design - looking for long-time relationship

  9. #9
    Join Date
    Nov 2001
    Location
    Vancouver
    Posts
    2,416
    Quote Originally Posted by xelav
    2mwatkins: I think, he has written php/mysql application, and need a gui manager solution on java
    Could be; problem is the OP's question is vague on the point and the OP has posted and run (like "cut and run").
    “Even those who arrange and design shrubberies are under
    considerable economic stress at this period in history.”

  10. #10
    You aren't too clear on your design criteria, so I don't know if Java is a good choice for your application. Obvious Java, and every other real programming language, supports MySQL. But how is your app being deployed? Is it on one box or distributed? Are both GUi and web clients running over the network?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •