1

first i'm not much professional in JAVA programming but if you mentioned a code how hard is it I'll understand it ...

I want to create a desktop application that is connected with an online database to insert/retrieve data from it ... I've searched a lot on google but no useful answer for this and most of people say that it's impossible cuz the host provider avoid external access while i'm using bluehost/godaddy there is Remote MySQL available in the control panel ... so external access is available !!

And othere's said that I have to use php script to retrieve the database link and write it in the java code but no useful links ...

if one of these solutions are true so how can I dot it ?? and if there's another solution i'd be glad if you shared with me !!

0

1 Answer 1

1

And othere's said that I have to use php script to retrieve the database link and write it in the java code but no useful links ...

That doesn't sound right at all. Java can connect to MySQL on its on accord. If your program is Java-based, why add PHP into the mix? I'm a PHP developer myself and I haven't touched Java in a while, but:

Check up on Using MySQL With Java because you'll need to use the JDBC driver (MySQL Connector/J).

try {
    conn =
       DriverManager.getConnection("jdbc:mysql://IPADDRESSGOESHERE:PORTNUMBER/yourdatabase");

    // Do something with the Connection

} catch (SQLException ex) {
    // handle any errors
    System.out.println("SQLException: " + ex.getMessage());
    System.out.println("SQLState: " + ex.getSQLState());
    System.out.println("VendorError: " + ex.getErrorCode());
}
Sign up to request clarification or add additional context in comments.

2 Comments

I've already installed the connector/j and it's working fine but on localhost ... I still need to try it on the online sql database !!
@user1294027 Change localhost to the IP address of the host with your external MySQL database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.