Results 1 to 3 of 3
  1. #1
    dilanka007 is offline Member
    Join Date
    Jan 2010
    Rep Power

    Default can't write my jdbc class to manipulate mysql

    well, i recently installed netbeans 6.8 .
    from netbeans i can access and manipulate mysql 5.0 databse.

    from netbeans i could even manage to generate an entity class.

    but when i try to write a little datahelper class to manipulate my database..
    i cant get this jdbc working.

    my jdbc jar folder is placed in the lib folder

    i just typed the following line to see whther everything is working fine. Class.forName("com.mysql.jdbc.Driver");

    but this line doesn't get recognise by netbeans..
    am i doing something wrong..

    * To change this template, choose Tools | Templates
    * and open the template in the editor.

    package DAO;
    import java.util.*;
    import java.sql.*;
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.SQLException;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    * @author dilanka
    public class DataHelper{

    //Connection conn = null;
    //String userName ="root";
    //String password = "dilan";
    //String url = "jdbc:mysql://localhost:3306/bidbizz";
    // DataHelper(){}

    conn = DriverManager.getConnection (url, userName, password);

    i am a new member to this forum.. plz just help me..

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power


    The code as is doesn'y make much sense, i.e. you have to stick that driver loading code in a method somewhere; maybe this'll do:

    Java Code:
    public class DataHelper {
    Connection conn;
    // Initialize everything in a helper for the constructor
    DataHelper() { 
    // initialize the driver
    private void initialize() {
       String userName= "root";
       String password= "dilan";
       String url= "jdbc:mysql://localhost:3306/bidbizz";
       conn= DriverManager.getConnection (url, userName, password);
    kind regards,


  3. #3
    dilanka007 is offline Member
    Join Date
    Jan 2010
    Rep Power


    Hey Jos,

    Thank You very much.. well yes i haven't thought of that small thing..
    well the problem is solved now ..
    thanks again..

    Best Regards

Similar Threads

  1. JDBC and mySQL database trouble
    By ichwar in forum JDBC
    Replies: 17
    Last Post: 08-16-2010, 11:21 PM
  2. Replies: 4
    Last Post: 03-31-2010, 12:08 PM
  3. JDBC data retrieval with MySQL
    By hadesflames in forum JDBC
    Replies: 5
    Last Post: 04-23-2009, 04:38 AM
  4. MySQL/JDBC Mysql query output
    By thelinuxguy in forum Advanced Java
    Replies: 4
    Last Post: 02-13-2009, 01:57 AM
  5. help ... JDBC or PHP/MySQL
    By bluebarca in forum Advanced Java
    Replies: 1
    Last Post: 11-16-2007, 10:05 AM

Tags for this Thread

Posting Permissions

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