applet not initialized

hie

i have made 2 classes one of client and the other of DBConnection. The client first allow access to the person by asking for username and password which is in the database after that shows the person some reports which are also taken from various tables in the database which is made in the database the tools i am using for it are JBuilder 6 and mysql 4.0 now when i compile the code it gets compile but when i try to run the html file it shows me applet not initialized and below it gives me following errors.

java.lang.NoClassDefFoundError: java/sql/Savepoint
     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
     at java.sql.DriverManager.getConnection(DriverManager.java:517)
     at java.sql.DriverManager.getConnection(DriverManager.java:177)
     at clientapp.DBConnection.<init>(DBConnection.java:20)
     at clientapp.client.<init>(client.java:64)
     at java.lang.Class.newInstance0(Native Method)
     at java.lang.Class.newInstance(Class.java:237)
     at sun.applet.AppletPanel.createApplet(AppletPanel.java:579)
     at sun.applet.AppletPanel.runLoader(AppletPanel.java:515)
     at sun.applet.AppletPanel.run(AppletPanel.java:293)
     at java.lang.Thread.run(Thread.java:484)

please help me out what will be the problem and how to solve it.

waiting for your answer
bkniaziAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
You need to upgrade JB's JDK to >= 1.4
CEHJCommented:
(or whatever VM the applet is running against)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Manikandan ThiagarajanSenior consultantCommented:
check jvm is there in browser.

check the both  class name.


upgrade the jdk version as per CEHJ told.
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Mick BarryJava DeveloperCommented:
> You need to upgrade JB's JDK to >= 1.4

You don't need to upgrade your JDK.

Check what the plugin is using as its default vm, appears its not using the same as jbuilder is.
May also be worth changing your html to iuse the <object> tag to check that a 1.4+ vm is being used. That will also give the user the option to install it if not there.

Let me know if u have any questions :)


CEHJCommented:
>>You don't need to upgrade your JDK.

I didn't say that the JDK definitely needs to be upgraded. I said that the current VM needs to upgraded if  bkniazi wants to run against it, a point your comment reiterates in another form
Mick BarryJava DeveloperCommented:
Have a look at the plugin control panel to see what vm your browser is using.
bkniaziAuthor Commented:
hie thanx for your answers but one thing that i forgot to mention was that this code is working on windows environment but i want to compile this code on LINUX and linux is giving me errors on it. i just started using JDK 1.5.0_02

Can you help me out with it i am pasting my code and the errors i am having in this window please help me out.

THE CODE:

package clientapp;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JPanel;
import se.datadosen.component.RiverLayout;
import javax.swing.*;

import java.sql.*;
import java.util.*;

import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.JComboBox;

public class client extends JApplet implements ActionListener {
  private boolean isStandalone = false;
  public Container cp = getContentPane();
  Vector columnHeads = new Vector();
  Vector opp = new Vector();
  public int rBG,gBG,bBG,rFG,bFG,gFG,rTC,bTC,gTC;
  public String BgColor,FgColor,TColor;
  public String query,query1;
  private boolean DEBUG = false;
  private boolean ALLOW_COLUMN_SELECTION = false;
  private boolean ALLOW_ROW_SELECTION = true;
  Vector rows = new Vector();
  public int  selectedRow;
  public boolean clickquery1=false,access=false;
  public String tablefield;
  public String tablename;
  //Get a parameter value
  JPanel main=new JPanel();
  JPanel grid=new JPanel();
  JPanel filter=new JPanel();
  JTextField Login=new JTextField(15);
  JPasswordField Password=new JPasswordField(15);
  JButton Submit=new JButton("Submit");
  JButton Filter=new JButton("Filter");
  JButton Find=new JButton("Find");
  JLabel month=new JLabel("Month");
  JLabel year=new JLabel("Year");
  JComboBox Month=new JComboBox();
  String monthtosearch="";
  String yeartosearch="";
  JTextField calledno=new JTextField(15);
  JLabel l5=new JLabel("Enter The Number You Want To Search");
  JLabel l9=new JLabel("Select A Month From The List");
  JLabel Sresults=new JLabel("............................................................Your Search Results Are............................................................");
  JLabel l6=new JLabel("===========================");
  JLabel l8=new JLabel("===========================");
  JLabel l7=new JLabel("");
  JLabel Llogin=new JLabel("Login");
  JLabel Plogin=new JLabel("Password");
  String[] todostring = {"-------","CalledNo", "Date", "Account Information" };
  JComboBox selections = new JComboBox(todostring);
  public String Accountid="";

  JComboBox Year=new JComboBox();
 DBConnection db=new DBConnection();
 public Connection connection=db.connect;

  public JTable table,ttable;
  public JScrollPane scroller1;

 public Statement statement;
 public ResultSet resultSet;
  public String getParameter(String key, String def) {
    return isStandalone ? System.getProperty(key, def) :
        (getParameter(key) != null ? getParameter(key) : def);
  }

  //Construct the applet
    public client() {


 setColorScheme();

    cp.add(new JLabel(""));
    filter.setLayout(new RiverLayout());
     main.setBackground(new Color(rBG,bBG,gBG));
     cp.setBackground(new Color(rBG,bBG,gBG));
     main.setForeground(new Color(rFG,bFG,gFG));
     cp.setForeground(new Color(rFG,bFG,gFG));
    main.setLayout(new RiverLayout());
    main.add("p left",Llogin);
    main.add("tab",Login);
    main.add("br",Plogin);
    main.add("tab",Password);
    main.add("br",new JLabel());
    main.add("tab",Submit);
    main.add("br",new JLabel(" "));
    main.add("br",new JLabel(" "));
    main.add("br",selections);
    main.add("br",l7);
    main.add("br",l7);
    main.add("br",l6);
    main.add("br",l5);
    main.add("br",calledno);
    main.add("br",Filter);

   l5.setForeground(new Color(rFG,bFG,gFG));
   l6.setForeground(new Color(rFG,bFG,gFG));
   l7.setForeground(new Color(rFG,bFG,gFG));
   l8.setForeground(new Color(rFG,bFG,gFG));
   l9.setForeground(new Color(rFG,bFG,gFG));
   month.setForeground(new Color(rFG,bFG,gFG));
   year.setForeground(new Color(rFG,bFG,gFG));
   Llogin.setForeground(new Color(rFG,bFG,gFG));
   Plogin.setForeground(new Color(rFG,bFG,gFG));

    main.add("br",l8);
    main.add("br",l7);
    main.add("br",l7);
    main.add("br",l9);
    main.add("br",month);
    main.add("tab",Month);
    main.add("br",year);
    main.add("tab",Year);
    main.add("br",Find);

    main.add("br",new JLabel());

    cp.add(main,BorderLayout.WEST);

    Month.setVisible(false);
    Year.setVisible(false);
    l5.setVisible(false);
    calledno.setVisible(false);
    month.setVisible(false);
    year.setVisible(false);
    year.setVisible(false);
    Filter.setVisible(false);
    Find.setVisible(false);
    selections.setVisible(false);
    l6.setVisible(false);
    l8.setVisible(false);
    l9.setVisible(false);

    Month.addItem("       Select         ");
    Month.addItem("January");
    Month.addItem("Febuary");
    Month.addItem("March");
    Month.addItem("April");
    Month.addItem("May");
    Month.addItem("June");
    Month.addItem("July");
    Month.addItem("August");
    Month.addItem("September");
    Month.addItem("October");
    Month.addItem("November");
    Month.addItem("December");
    Year.addItem("       Select         ");
    Year.addItem("2005");
    Submit.addActionListener(this);
    Filter.addActionListener(this);
    Find.addActionListener(this);

  }
  //Initialize the applet
  public void init() {
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  //Component initialization
  private void jbInit() throws Exception {
  }
  //Get Applet information
  public String getAppletInfo() {
    return "Applet Information";
  }
  //Get parameter info
  public String[][] getParameterInfo() {
    return null;
  }
  public void actionPerformed(ActionEvent e)
  {
    Object a=e.getSource();
    if(a==Submit)
    {
      checklogin(Login.getText(),Password.getText());
    }

  }


  private void getTable(String q)
  {
    try {

      String query = q;
      statement = connection.createStatement();
      resultSet = statement.executeQuery( query );
      displayResultSet( resultSet );
      statement.close();
    }
    catch ( SQLException sqlex ) {
        sqlex.printStackTrace();
    }
  }
  private void displayResultSet( ResultSet rs )
      throws SQLException
  {
    // position to first record


    boolean moreRecords = rs.next();

    // If there are no records, display a message
    if ( ! moreRecords && clickquery1==true) {
      JOptionPane.showMessageDialog( this,
                                     "Required record does not exist in the database" );
      //    ff.show();
      // setTitle( "No records to display" );
      return;
    }

    if (  !moreRecords) {
      Vector columnHeads = new Vector();
      Vector rows = new Vector();
      //    Vector rows = new Vector();
      //  JOptionPane.showMessageDialog( this,
      // "ResultSet contained no records" );

      ResultSetMetaData rsmd = rs.getMetaData();
      for ( int i = 1; i <= rsmd.getColumnCount(); ++i )
        columnHeads.addElement( rsmd.getColumnName( i ));

      //   for ( int i = 1; i <= rsmd.getColumnCount(); ++i )
      //   rows.addElement(rsmd.getColumnName( i ).substring(1,2));
//System.out.println(rows.toString());

      table = new JTable( rows, columnHeads );

      // setTitle( "No records to display" );
      return;
      //return;

    }

    // setTitle( "DataGrid" );
    try {
      Vector columnHeads = new Vector();
      Vector rows = new Vector();
      // get column heads
      ResultSetMetaData rsmd = rs.getMetaData();

      for ( int i = 1; i <= rsmd.getColumnCount(); ++i )

        columnHeads.addElement( rsmd.getColumnName( i ));

      // get row data
      do {

        String starttime=rs.getString("StartTime");
        String monthreturned=getMonth(starttime);
        if(monthtosearch.equalsIgnoreCase(monthreturned))
          {
            rows.addElement( getNextRow( rs, rsmd ) );
          }
          if(monthtosearch.equalsIgnoreCase(""))
          {
            rows.addElement( getNextRow( rs, rsmd ) );
          }
      } while ( rs.next() );

      // display table with ResultSet contents
      opp=rows;

      table = new JTable( rows, columnHeads );
      setColorScheme();
      table.setBackground(new Color(rBG,bBG,gBG));
      table.setForeground(new Color(rFG,bFG,gFG));

      table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

      if (ALLOW_ROW_SELECTION) { // true by default
        ListSelectionModel rowSM = table.getSelectionModel();
        rowSM.addListSelectionListener(new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            //Ignore extra messages.
            if (e.getValueIsAdjusting()) return;

            ListSelectionModel lsm = (ListSelectionModel)e.getSource();

            if (lsm.isSelectionEmpty()) {
              //  System.out.println("No rows are selected.");
            } else {
              selectedRow = lsm.getMinSelectionIndex();
              //  System.out.println("Row " + selectedRow
              //               + " is now selected.");

            }
          }
        });
      } else {
        table.setRowSelectionAllowed(false);
      }
      // p1.add(butt.setLayout(new FlowLayout.RIGHT);
      //getContentPane().add(
      //scroller1, BorderLayout.CENTER );

    }
    catch ( SQLException sqlex ) {
      // sqlex.printStackTrace();
    }
  }
  private Vector getNextRow( ResultSet rs,
                             ResultSetMetaData rsmd )
      throws SQLException
  {
    Vector currentRow = new Vector();
    String a=new String();
    for ( int i = 1; i <= rsmd.getColumnCount(); ++i )
      switch( rsmd.getColumnType( i ) ) {
    case Types.TIMESTAMP:
      currentRow.addElement( rs.getString(i).substring(0,11)) ;
      break;
      //System.out.println( rs.getString( i ).substring(0,11) );
      // a= rs.getString( i ).substring(11,0) ;

      //  break;
    case Types.NUMERIC:
      currentRow.addElement( new Long( rs.getLong( i ) ) );
      break;

      //currentRow.addElement( new Long( rs.getLong( i ) ) );
      //   case Types.DECIMAL:
      ///   case Types.FLOAT:
      //     currentRow.addElement( new Float( rs.getFloat( i ) ) );
      //     break;
    default:
      currentRow.addElement( rs.getString( i ) );
    // System.out.println( "Type was: " +
    //   rsmd.getColumnTypeName( i ) );
    }

    return currentRow;
  }
  public void setColorScheme()
  {

    String str="Select * from ConsoleColorScheme where Status = 'Active'";
    try {
      Statement statement = connection.createStatement();
      ResultSet rs = statement.executeQuery( str );
      int recordNumber;

      while (rs.next()) {
        BgColor=rs.getString(3).toString();
        FgColor=rs.getString(4).toString();

      }
      if(BgColor!=null && FgColor!=null){
        StringTokenizer bgstr=new StringTokenizer(BgColor,",");
        rBG=Integer.parseInt(bgstr.nextToken().toString());
        bBG=Integer.parseInt(bgstr.nextToken().toString());
        gBG=Integer.parseInt(bgstr.nextToken().toString());
        StringTokenizer fgstr=new StringTokenizer(FgColor,",");
        rFG=Integer.parseInt(fgstr.nextToken());
        bFG=Integer.parseInt(fgstr.nextToken());
      gFG=Integer.parseInt(fgstr.nextToken());}
      else
      {rBG=204;bBG=204;gBG=204;
      rFG=0;bFG=0;gFG=0;}
    }

    catch ( SQLException sqlex ) {
      // sqlex.printStackTrace();
      //  System.out.println( sqlex.toString() );
    }
  }
  public void checklogin(String l,String p)
  {

    String str="Select AccountID,Username,Password from AccountInfo where Username="+"'"+l+"'"+" and Password="+"'"+p+"'"+"";

    try {
      Statement statement = connection.createStatement();
      ResultSet rs = statement.executeQuery( str );
      int recordNumber=0;
      while (rs.next()) {
        recordNumber=recordNumber+1;
        Accountid=rs.getString("AccountID");
      }
      String str1="Select AccountID,CallerNo,CalledNo,StartTime,EndTime,Duration,TotalCharges from callsinfo where AccountID="+"'"+Accountid+"'"+"";
      //String str1="Select * from callsinfo where AccountID="+"'"+Accountid+"'"+"";
      if(recordNumber==0)
      {
        JOptionPane.showMessageDialog(this,"Invalid Login/Password");
        Login.setText("");
        Password.setText("");
      }
      else
      {
        refresh(str1);
        Submit.setEnabled(false);

        selections.setVisible(true);



   selections.addActionListener(new ActionListener()
                     {
                       public void actionPerformed(ActionEvent e)
                       {
                         JComboBox cb = (JComboBox)e.getSource();
                         String optionforsearch = (String)cb.getSelectedItem();

                         if(optionforsearch.equalsIgnoreCase("calledNo"))
                         {
                           l6.setVisible(true);
                           l8.setVisible(true);
                           l9.setVisible(false);
                           Month.setVisible(false);
                           Year.setVisible(false);
                           month.setVisible(false);
                           year.setVisible(false);
                           Find.setVisible(false);

                           l5.setVisible(true);
                           calledno.setVisible(true);
                           Filter.setVisible(true);
                         }


                         if(optionforsearch.equalsIgnoreCase("Date"))
                         {
                              l6.setVisible(false);
                              l5.setVisible(false);
                              calledno.setVisible(false);
                              Filter.setVisible(false);
                              l9.setVisible(true);

                              month.setVisible(true);
                              year.setVisible(true);
                              Month.setVisible(true);
                              Year.setVisible(true);
                              Find.setVisible(true);
                         }

                       }
        });


        Filter.addActionListener(new ActionListener()
                     {
                       public void actionPerformed(ActionEvent e)
                       {
                          String cmm=e.getActionCommand();
                          if(cmm.equalsIgnoreCase("Filter"))
                          {

    String numbertosearch=calledno.getText();
    String query="Select AccountID,CallerNo,CalledNo,StartTime,EndTime,Duration,TotalCharges from callsinfo where AccountID="+"'"+Accountid+"'"+" and CalledNo="+"'"+numbertosearch+"'"+"";
    //String query="Select * from callsinfo where AccountID="+"'"+Accountid+"'"+" and CalledNo="+"'"+numbertosearch+"'"+"";
    filtereddata(query);
                          }
                       }
                     });

  Find.addActionListener(new ActionListener()
                     {
                       public void actionPerformed(ActionEvent e)
                       {
                  String cmm=e.getActionCommand();
                  if(cmm.equalsIgnoreCase("Find"))
                   {

                    monthtosearch=Month.getSelectedItem().toString();
                    monthtosearch=monthtosearch.substring(0,3);
                    yeartosearch=Year.getSelectedItem().toString();

                String query="Select AccountID,CallerNo,CalledNo,StartTime,EndTime,Duration,TotalCharges from callsinfo where AccountID="+"'"+Accountid+"'"+"";
               //String query="Select * from callsinfo where AccountID="+"'"+Accountid+"'"+"";

                filtereddata(query);


                          }
                       }
                     });


        this.setSize(1024,768);
      }
    }

    catch ( SQLException sqlex ) {
         sqlex.printStackTrace();
        System.out.println( sqlex.toString() );
    }
  }
  public void refresh(String tb)

  {
    String query=tb;
    getTable(query);
    grid();
  }
  public void grid()
  {
    table.setAutoResizeMode(table.AUTO_RESIZE_OFF);
    scroller1=new JScrollPane(table);
    scroller1.setForeground(new Color(rBG,gBG,bBG));
    cp.repaint();
    scroller1.setPreferredSize(new Dimension(600,400));//750,600));
    grid.setLayout(new RiverLayout());
    grid.add("p tab",Sresults);
    grid.add("br",l7);
    grid.add("p left",scroller1);
    cp.add(grid);
    validate();
  }
  public void filtereddata(String query)
  {

    grid.remove(scroller1);
    cp.remove(grid);
    validate();
    getTable(query);
    grid();
  }

StringTokenizer st;

  public String getMonth(String monthtosearch)
  {

st=new StringTokenizer(monthtosearch);

String dayoftheweek=st.nextToken();
String monthoftheyear=st.nextToken();

return monthoftheyear;

  }
}

AND THE ERRORS WHICH I AM HAVING ARE

java.lang.VerifyError: (class: clientapp/client, method: checklogin signature: (Ljava/lang/String;Ljava/lang/String;)V) Incompatible object argument for function call
      at java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
      at java.lang.Class.getConstructor0(Class.java:2640)
      at java.lang.Class.newInstance0(Class.java:321)
      at java.lang.Class.newInstance(Class.java:303)
      at sun.applet.AppletPanel.createApplet(AppletPanel.java:710)
      at sun.applet.AppletPanel.runLoader(AppletPanel.java:639)
      at sun.applet.AppletPanel.run(AppletPanel.java:319)
      at java.lang.Thread.run(Thread.java:595)
Mick BarryJava DeveloperCommented:
if you're compiling with 1.5 use the -target and -source options to build 1.4 classes, and recompile all the classes

javac -target 1.4 -source 1.4   ....
bkniaziAuthor Commented:
hie

well i tried the said thing but the problem is still there now when i removed all the Database queries and connection the applet loads and loads well but it is too slow. And when i put some of the database queries again comes the applet not initialized error and following is the error code which Jbuilder gives

SQLException: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: java.net.ConnectException: Connection timed out

STACKTRACE:

java.net.SocketException: java.net.ConnectException: Connection timed out
      at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
      at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
      at com.mysql.jdbc.Connection.createNewIO(Connection.java:2555)
      at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
      at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
      at java.sql.DriverManager.getConnection(DriverManager.java:525)
      at java.sql.DriverManager.getConnection(DriverManager.java:171)
      at clientapp.DBConnection.<init>(DBConnection.java:34)
      at clientapp.client.<init>(client.java:64)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
      at java.lang.Class.newInstance0(Class.java:350)
      at java.lang.Class.newInstance(Class.java:303)
      at sun.applet.AppletPanel.createApplet(AppletPanel.java:710)
      at sun.applet.AppletPanel.runLoader(AppletPanel.java:639)
      at sun.applet.AppletPanel.run(AppletPanel.java:319)
      at java.lang.Thread.run(Thread.java:595)


** END NESTED EXCEPTION **


please help me out
Mick BarryJava DeveloperCommented:
looks like it is faiuling to connect to the database.
make sure you are connecting to the correct machine, and the database is running and listening on that port.
bkniaziAuthor Commented:
how can i check this thing please help me out
bkniaziAuthor Commented:
hie well i checked one thing that when i make the code work without the database it surely work and one i make an object of the database class in the main class it also works fine and the applet loads. So what i did i put some dummy data in the database tables and tried to connect to the database it gives me the following error:


SQLException: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: java.net.ConnectException: Connection timed out

STACKTRACE:

java.net.SocketException: java.net.ConnectException: Connection timed out
     at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
     at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
     at com.mysql.jdbc.Connection.createNewIO(Connection.java:2555)
     at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
     at java.sql.DriverManager.getConnection(DriverManager.java:525)
     at java.sql.DriverManager.getConnection(DriverManager.java:171)
     at clientapp.DBConnection.<init>(DBConnection.java:34)
     at clientapp.client.<init>(client.java:64)
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
     at java.lang.Class.newInstance0(Class.java:350)
     at java.lang.Class.newInstance(Class.java:303)
     at sun.applet.AppletPanel.createApplet(AppletPanel.java:710)
     at sun.applet.AppletPanel.runLoader(AppletPanel.java:639)
     at sun.applet.AppletPanel.run(AppletPanel.java:319)
     at java.lang.Thread.run(Thread.java:595)


** END NESTED EXCEPTION **




NOW the question is that i think that the my Jconnector is not working fine . Now what can be problem with it . The driver can be corrupt for this i tried other Jconnector plzzzz help me out i am in deep trouble i am waiting for response.

thanks in advance
Mick BarryJava DeveloperCommented:
it doesn't look like a problem with the connector or the database.
It is failing to connect to the database, suggesting that it isn't running/listening on the box you are trying to connect to it on.
Check your connect string is pointing at the right database.
bkniaziAuthor Commented:
hie

well i changed my connection string completely but the problem is still there i am pasting my code of database connection class please  have a look at it and help me out

THE CODE:

import java.sql.*;
import java.awt.*;
import java.util.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


  public class DBConnection {
    public Connection connect;
        public DBConnection()
         {
          try
          {      // Load driver class                                                                          ///
                                                                                                             ///
            Connection con = null;                                                                              ///
            String url = "jdbc:mysql://localhost/softswitch";                                                   ///
            Class.forName("com.mysql.jdbc.Driver");                                                             ///
            con = DriverManager.getConnection( url, "", "" );                                                   ///
            Statement stmt = con.createStatement();                                                             ///

            }                                                                                                    ///
            catch(Exception e )
            {                                                                                ///
            }                                                                                                    ///
                                                                                                             ///
            Connection con = null;                                                                               ///
            try
             {                                                                                                ///
                                                                                                             ///
                connect = DriverManager.getConnection( "jdbc:mysql://localhost/softswitch", "", "" );                  ///

              }                                                                                                    ///
            catch (SQLException ex)                                                                              ///
            {                                                                                                ///
              System.err.println("SQLException: " + ex);                                                         ///
            }                                                                                                    ///
            finally                                                                                              ///
            {                                                                                                    ///
              if (con != null)                                                                                   ///
              try                                                                                              ///
              {
                JOptionPane.showMessageDialog(null,"Database Connection Error");
                connect.close();
              }                                                                                                  ///
              catch (SQLException ex)                                                                            ///
              {                                                                                              ///
                System.err.println("SQLException: " + ex);                                                        ///
              }                                                                                                  ///
         }
  }
}

And the error i am facing is this

****************************************************************************
SQLException: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: java.net.ConnectException: Connection timed out

STACKTRACE:

java.net.SocketException: java.net.ConnectException: Connection timed out
      at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
      at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
      at com.mysql.jdbc.Connection.createNewIO(Connection.java:2555)
      at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
      at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
      at java.sql.DriverManager.getConnection(DriverManager.java:525)
      at java.sql.DriverManager.getConnection(DriverManager.java:171)
      at clientapp.DBConnection.<init>(DBConnection.java:34)
      at clientapp.client.<init>(client.java:64)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
      at java.lang.Class.newInstance0(Class.java:350)
      at java.lang.Class.newInstance(Class.java:303)
      at sun.applet.AppletPanel.createApplet(AppletPanel.java:710)
      at sun.applet.AppletPanel.runLoader(AppletPanel.java:639)
      at sun.applet.AppletPanel.run(AppletPanel.java:319)
      at java.lang.Thread.run(Thread.java:595)


** END NESTED EXCEPTION **

****************************************************************************
Manikandan ThiagarajanSenior consultantCommented:
CEHJCommented:
1. Determine that the db is running on the expected port:

netstat -an | find "<insert expected port number>"

2. If so, include that port in the connection string
Mick BarryJava DeveloperCommented:
> String url = "jdbc:mysql://localhost/softswitch";    

try specify the port it is listening on, eg.

String url = "jdbc:mysql://localhost:3306/softswitch";    
bkniaziAuthor Commented:
hie i did the same thing as told by objects to change it to port but still the same error comes which then changes my thought as this is not the problem of java infact it is the problem of connectivity so i thought to check whether the port 3306 is open or not for this reason i checked it by the entering this command in the terminal

ps -ae | grep mysql

and the result i get was

3286 ?        00:00:00 mysqld_safe
 3318 ?        00:00:00 mysqld
 3321 ?        00:00:00 mysqld
 3322 ?        00:00:00 mysqld
 3323 ?        00:00:00 mysqld
 3324 ?        00:00:00 mysqld
 3325 ?        00:00:00 mysqld
 3328 ?        00:00:00 mysqld
 3329 ?        00:00:00 mysqld
 3330 ?        00:00:00 mysqld
 3331 ?        00:00:00 mysqld

can you help me out what is the problem regards

Mick BarryJava DeveloperCommented:
open the mysql admin app and check that it is set to listen, and if so what port
bkniaziAuthor Commented:
it is listening at port 3306
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.