need help with Jdbc - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

need help with Jdbc

cloudncalicloudncali Posts: 35Member
[b][red]This message was edited by cloudncali at 2007-1-7 11:25:4[/red][/b][hr]
it seems like people are getting this alot. the "No sutable Driver" error. and i got it too. I have been working for an entire day and have gottan NOWHERE with this no matter what i do i still get this error.
here is the code if ithelps
Class.forName("com.mysql.jdbc.Driver").newInstance();
i have tryed every thing, includeing the Classpath method. and for the first time google has failed me :(

can any one help me?

edit:
I might also add there was no CLASSPATH in my system var's. so i made one? but im not sure i did this right





Comments

  • cloudncalicloudncali Posts: 35Member
    [b][red]This message was edited by cloudncali at 2007-1-7 12:10:19[/red][/b][hr]
    ok guys I REALY need help with this .I'm about ready to give up I have tryed every thing I can think of but I still get the same error. is there any one that knows how to fix this?


  • pahpah Posts: 83Member
    : [b][red]This message was edited by cloudncali at 2007-1-7 12:10:19[/red][/b][hr]
    : ok guys I REALY need help with this .I'm about ready to give up I have tryed every thing I can think of but I still get the same error. is there any one that knows how to fix this?
    :
    :
    :
    OK i hope i can help you...

    first in the new jdk version 6 i heared you dont need the class for name registration but lets do it with this.

    i only worked with a postgre sql database but it should be the same.


    [code]

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.sql.ResultSet;

    public class foo{

    private String m_sPort;
    private String m_sUrl;
    private String m_sUser;
    private String m_sPsw;
    private String m_sDB;
    private String m_sConnectionString;


    private Statement m_dbStatement;
    private Connection m_dbConn;
    private ResultSet m_dbResult;

    public foo(){

    //init. here the string variables the db user port and the password etc.

    }

    public void openConnction(){
    sConnectionString = "jdbc:YOURDRIVER://"+ m_sUrl +":"+m_sPort+":"+m_sDB;
    try{
    Class.forName("org.YOURDATABASE.DRIVER") //for posrgresql org.postgresql.Driver

    m_dbConn = DriverManager.getConnection(sConnectionString,m_sUser,m_sPsw);

    //then create a statement and through the statement execute your
    //SQL code..
    m_dbStatement = m_dbConn.createStatement();
    m_dbResult = m_dbStatement.executeQuery(sqlQuerie);

    }catch(ClassNotFoundException ex(){}
    catch(SQLException ex){}
    }

    }

    [/code]


    i hope this helps i didnt sleep for days and i am not home on my pc.....
    too much out of brain..... ;-()
Sign In or Register to comment.