Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: driver installed but still same error regarding connecting to mysql

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default driver installed but still same error regarding connecting to mysql

    hello,

    package g;

    import java.sql.*;
    /**
    *
    * @author ankit
    */
    public class m extends javax.swing.JFrame {

    /**
    * Creates new form m
    */
    public m() {
    initComponents();
    }

    /**
    * This method is called from within the constructor to initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is always
    * regenerated by the Form Editor.
    */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    db = new javax.swing.JComboBox();

    setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);

    db.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    db.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    dbActionPerformed(evt);
    }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(138, 138, 138)
    .addComponent(db, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(180, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(72, 72, 72)
    .addComponent(db, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(201, Short.MAX_VALUE))
    );

    pack();
    }// </editor-fold>

    private void dbActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
    * For details see How to Set the Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)
    */
    try {
    for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
    if ("Nimbus".equals(info.getName())) {
    javax.swing.UIManager.setLookAndFeel(info.getClass Name());
    break;
    }
    }
    } catch (ClassNotFoundException ex) {
    java.util.logging.Logger.getLogger(m.class.getName ()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
    java.util.logging.Logger.getLogger(m.class.getName ()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
    java.util.logging.Logger.getLogger(m.class.getName ()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
    java.util.logging.Logger.getLogger(m.class.getName ()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */

    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new m().setVisible(true);
    }
    });
    }

    // Variables declaration - do not modify
    private javax.swing.JComboBox db;
    // End of variables declaration

    String username="root",password="cutiepie_100",host="loca lhost";

    Class.forName("com.mysql.jdbc.Driver");

    }

    and the error is

    run:
    Exception in thread "main" java.lang.ClassFormatError: Method "<error>" in class g/m has illegal signature "(Ljava/lang/ObjectLjava/lang/Class$forName;"
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java :760)
    at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader .java:455)
    at java.net.URLClassLoader.access$100(URLClassLoader. java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 367)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:4 24)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308) at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 57)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Launc herHelper.java:495)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)

    i haveset classpath jconnector but still this result


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: driver installed but still same error regarding connecting to mysql

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly using code or highlight tags per the above link.

    Give your classes meaningful, useful names that start with capital letters. We generally do not help with GUI code generated by drag-and-drop code generators.

  3. #3
    Junior Member
    Join Date
    Sep 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: driver installed but still same error regarding connecting to mysql

    Quote Originally Posted by GregBrannon View Post
    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly using code or highlight tags per the above link.

    Give your classes meaningful, useful names that start with capital letters. We generally do not help with GUI code generated by drag-and-drop code generators.
    Class.forName("com.mysql.jdbc.Driver");
    this line shows class not found

Similar Threads

  1. Replies: 22
    Last Post: August 30th, 2013, 09:31 PM
  2. Replies: 2
    Last Post: August 2nd, 2013, 10:25 PM
  3. Problems connecting to mysql database on network
    By 2k. in forum JDBC & Databases
    Replies: 10
    Last Post: May 8th, 2012, 08:54 PM
  4. JCombobox connecting to mysql
    By myexternall11 in forum JDBC & Databases
    Replies: 2
    Last Post: February 16th, 2012, 11:04 PM
  5. java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    By i4ba1 in forum JDBC & Databases
    Replies: 2
    Last Post: August 23rd, 2011, 12:41 PM

Tags for this Thread