Unable to access mysql database through JDBC Connection string

Posted on 2005-05-06
Last Modified: 2011-09-20
We have a Cpanel User Account, through which we are able to login and able to access the cpanel features, when we using this user account through JDBC connection string, we are unable to access the mysql database. Then what precautions has to be take when using the JDBC connection string ?
Question by:tulasisiva
    LVL 1

    Accepted Solution

    Ok, I've not got alot of information to go on here, but I'll try to help.

    Obviously, you should import java.sql.*;

    What JDBC connector are you using?  I'd suggest Connector/J
    (you can find it at

    In your accessing class, you need to declare the driver using the following code:

    //The newInstance() call is a work around for some broken Java implementations

    Then you'll need to obtain a connection for the database using the following code:

    String url = "jdbc:mysql:http://hostname.domain/database_name";
    Connection con = DriverManager.getConnection(url, "username", "password");

    Updates and Queries to the database can be made using the Statement type.
    e.g.  Statement stmt = con.createStatement();

    The syntax for this is: stmt.executeUpdate(String_name); where 'String_name' is
    the sql command to update the table.

    there is also stmt.executeQuery.  you'll need to create a ResultSet to retrieve the
    results from this.

    Hope this helps.

    LVL 1

    Expert Comment

    oops, the url String in the above is incorrect.

    it should read: String url = "jdbc:mysql://hostname.domain/database_name";

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    has22 challenge 11 56
    ImportError: No module named 'pypyodbc' - python 3.5.2 3 246
    linearIn  challenge 23 54
    nestparen challenge 4 36
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now