hello please help me i have a program and i want to connect to the database i don't have any idea on how to connect because im still a begginer on this..help me please how to connect to the database,hoping for your positive responds

if you're still a beginner, connecting to databases might not be the best place to start.
anyway, how to connect depends on several things, what kind of database, is there a password, ... and since you don't tell anything about that, I'm not going on a wild goose chase.
the next link however should give you a good idea about what you need and how you should proceed:
JDBC at http://java.sun.com/

ahm can you help me with password connection and without the password so that i can have idea on this..hoping for your positive responds

ahm can you help me with password connection and without the password so that i can have idea on this..hoping for your positive responds

ehm.. well, did you check the link I've suggested? in order to connect to a DB, you'll need to use the right jdbc driver.
here you'll find an example of how to connect to a MySQL DB

Well...this is a code snippet to connect to oracle data base using type-1 driver using your java program:...hope this helps you......

import java.sql.*;
class DbConnection 
{
    public static void main(String[] args) 
    {
        try{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con=DriverManager.getConnection("jdbc:odbc:Fardoon","scott","tiger");
        DatabaseMetaData dbmd=con.getMetaData();
        String str=dbmd.getDatabaseProductName();
        System.out.println("The name of the database you are using is: "+str);
        con.close();
        }//end of try
        catch(SQLException e){
            e.printStackTrace();
        }
        catch(Exception e){
            e.printStackTrace();
        }


    }//end of main
}//end of class

1.Class.forName() method loads and registers the jdbc type-1 driver named sun.jdbc.odbc.JdbcOdbcDriver
2.DriverManager.getConnection() method The attempts to select an appropriate driver from the set of registered JDBC drivers
3.The DatabaseMetaData is an interface and is used to find the details of the
database you are connected to....
I used the DatabaseMetaData to confirm that you are connected to the database.
//"Fardoon" is the dsn name(userdefined) u create to connect to the database using the ODBC connection for oracle

you create an user dsn(data source name) by going to control panel->Administrative tools->Data Sources(ODBC)->Go for Add->select Microsoft ODBC for Oracle->select finish->then you get a dialog box and enter only the dsn name(ignore other text fields) and select ok...you can see the new dsn name in the user dsn list newly created...

thanks for the reply and for helping me i will write again if i have problem on this.more power to you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.