Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-09-2008, 02:47 PM
Member
 
Join Date: Jan 2008
Posts: 2
necro-1000 is on a distinguished road
Help needed.
First of all hi, I hope I am posting in the right forum hehe.

Well, I am trying to write a small program that connected to an online database using mySQL. By any chance does any1 know what is causing it?

These errors come up when I try to press the add button to add new information to the database.

I can also post the code that is making the program crash too,

Thanks for any help!

Quote:
init:
deps-jar:
Compiling 1 source file to J:\Java Assignment\HotelReservationSystem\build\classes
compile-single:
run-single:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at DB.DBRoutines.loadDatabaseDriver(DBRoutines.java:4 9)
at DB.DBRoutines.<init>(DBRoutines.java:39)
at System.HotelGUI.btnClientAddMouseClicked(HotelGUI. java:171)
at System.HotelGUI.access$000(HotelGUI.java:16)
at System.HotelGUI$1.mouseClicked(HotelGUI.java:77)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEvent Multicaster.java:212)
at java.awt.Component.processMouseEvent(Component.jav a:5520)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3135)
at java.awt.Component.processEvent(Component.java:528 2)
at java.awt.Container.processEvent(Container.java:196 6)
at java.awt.Component.dispatchEventImpl(Component.jav a:3984)
at java.awt.Container.dispatchEventImpl(Container.jav a:2024)
at java.awt.Component.dispatchEvent(Component.java:38 19)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:3901)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:3822)
at java.awt.Container.dispatchEventImpl(Container.jav a:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1791 )
at java.awt.Component.dispatchEvent(Component.java:38 19)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 463)
at java.awt.EventDispatchThread.pumpOneEventForHierar chy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:110)
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager .java:545)
at java.sql.DriverManager.getConnection(DriverManager .java:171)
at DB.DBRoutines.connect(DBRoutines.java:62)
at System.HotelGUI.btnClientAddMouseClicked(HotelGUI. java:172)
at System.HotelGUI.access$000(HotelGUI.java:16)
at System.HotelGUI$1.mouseClicked(HotelGUI.java:77)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEvent Multicaster.java:212)
at java.awt.Component.processMouseEvent(Component.jav a:5520)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3135)
at java.awt.Component.processEvent(Component.java:528 2)
at java.awt.Container.processEvent(Container.java:196 6)
at java.awt.Component.dispatchEventImpl(Component.jav a:3984)
at java.awt.Container.dispatchEventImpl(Container.jav a:2024)
at java.awt.Component.dispatchEvent(Component.java:38 19)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:3901)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:3822)
at java.awt.Container.dispatchEventImpl(Container.jav a:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1791 )
at java.awt.Component.dispatchEvent(Component.java:38 19)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 463)
at java.awt.EventDispatchThread.pumpOneEventForHierar chy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:110)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at System.HotelGUI.btnClientAddMouseClicked(HotelGUI. java:177)
at System.HotelGUI.access$000(HotelGUI.java:16)
at System.HotelGUI$1.mouseClicked(HotelGUI.java:77)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEvent Multicaster.java:212)
at java.awt.Component.processMouseEvent(Component.jav a:5520)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3135)
at java.awt.Component.processEvent(Component.java:528 2)
at java.awt.Container.processEvent(Container.java:196 6)
at java.awt.Component.dispatchEventImpl(Component.jav a:3984)
at java.awt.Container.dispatchEventImpl(Container.jav a:2024)
at java.awt.Component.dispatchEvent(Component.java:38 19)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:3901)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:3822)
at java.awt.Container.dispatchEventImpl(Container.jav a:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1791 )
at java.awt.Component.dispatchEvent(Component.java:38 19)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 463)
at java.awt.EventDispatchThread.pumpOneEventForHierar chy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:110)
BUILD SUCCESSFUL (total time: 1 minute 27 seconds)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-12-2008, 09:17 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 739
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
necro, welcome to Java Forums!

Let's see some code.

See you around!
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on July 13, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-12-2008, 12:37 PM
Member
 
Join Date: Jan 2008
Posts: 2
necro-1000 is on a distinguished road
Here's the code, and thanks for the help!

Quote:
/*
* HotelGUI.java
*
* Created on 07 January 2008, 10:43
*/

package System;
import DB.DBRoutines;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.swing.JOptionPane;
/**
*
* @author andrpors
*/
public class HotelGUI extends javax.swing.JFrame {

/** Creates new form HotelGUI */
public HotelGUI() {
initComponents();
choClientType.add("");
choClientType.add("Business");
choClientType.add("Couple");
choClientType.add("Family");
choClientType.add("VIP");
}

/** 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

HotelPanes = new javax.swing.JTabbedPane();
ClientTab = new javax.swing.JPanel();
txtClientId = new javax.swing.JTextField();
lblClientId = new javax.swing.JLabel();
txtClientName = new javax.swing.JTextField();
lblClientName = new javax.swing.JLabel();
txtClientSurname = new javax.swing.JTextField();
lblClientSurname = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
txtClientAddress = new javax.swing.JEditorPane();
lblClientAddress = new javax.swing.JLabel();
txtClientTel = new javax.swing.JTextField();
lblClientTelephone = new javax.swing.JLabel();
lblClientMobile = new javax.swing.JLabel();
txtClientMobile = new javax.swing.JTextField();
choClientType = new java.awt.Choice();
lblClientType = new javax.swing.JLabel();
btnClientAdd = new javax.swing.JButton();

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

lblClientId.setText("Client ID");

lblClientName.setText("Name");

lblClientSurname.setText("Surname");

jScrollPane1.setViewportView(txtClientAddress);

lblClientAddress.setText("Address");

lblClientTelephone.setText("Telephone");

lblClientMobile.setText("Mobile");

lblClientType.setText("Client Type");

btnClientAdd.setText("Add");
btnClientAdd.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btnClientAddMouseClicked(evt);
}
});

org.jdesktop.layout.GroupLayout ClientTabLayout = new org.jdesktop.layout.GroupLayout(ClientTab);
ClientTab.setLayout(ClientTabLayout);
ClientTabLayout.setHorizontalGroup(
ClientTabLayout.createParallelGroup(org.jdesktop.l ayout.GroupLayout.LEADING)
.add(ClientTabLayout.createSequentialGroup()
.add(38, 38, 38)
.add(ClientTabLayout.createParallelGroup(org.jdesk top.layout.GroupLayout.LEADING)
.add(ClientTabLayout.createSequentialGroup()
.add(ClientTabLayout.createParallelGroup(org.jdesk top.layout.GroupLayout.TRAILING)
.add(lblClientSurname)
.add(lblClientName)
.add(lblClientTelephone)
.add(lblClientAddress)
.add(lblClientMobile)
.add(lblClientType))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
.add(ClientTabLayout.createParallelGroup(org.jdesk top.layout.GroupLayout.TRAILING, false)
.add(org.jdesktop.layout.GroupLayout.LEADING, txtClientMobile)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 229, Short.MAX_VALUE)
.add(txtClientName)
.add(txtClientSurname, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE)
.add(txtClientTel)
.add(org.jdesktop.layout.GroupLayout.LEADING, choClientType, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.add(18, 18, 18)
.add(btnClientAdd))
.add(ClientTabLayout.createSequentialGroup()
.add(lblClientId)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
.add(txtClientId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 73, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)))
.addContainerGap(15, Short.MAX_VALUE))
);
ClientTabLayout.setVerticalGroup(
ClientTabLayout.createParallelGroup(org.jdesktop.l ayout.GroupLayout.LEADING)
.add(ClientTabLayout.createSequentialGroup()
.add(ClientTabLayout.createParallelGroup(org.jdesk top.layout.GroupLayout.LEADING)
.add(ClientTabLayout.createSequentialGroup()
.addContainerGap()
.add(ClientTabLayout.createParallelGroup(org.jdesk top.layout.GroupLayout.BASELINE)
.add(lblClientId)
.add(txtClientId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED, 82, Short.MAX_VALUE)
.add(ClientTabLayout.createParallelGroup(org.jdesk top.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, ClientTabLayout.createSequentialGroup()
.add(ClientTabLayout.createParallelGroup(org.jdesk top.layout.GroupLayout.BASELINE)
.add(lblClientTelephone)
.add(txtClientTel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
.add(ClientTabLayout.createParallelGroup(org.jdesk top.layout.GroupLayout.BASELINE)
.add(txtClientMobile, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(lblClientMobile)))
.add(org.jdesktop.layout.GroupLayout.TRAILING, ClientTabLayout.createSequentialGroup()
.add(lblClientAddress)
.add(118, 118, 118))))
.add(ClientTabLayout.createSequentialGroup()
.add(56, 56, 56)
.add(ClientTabLayout.createParallelGroup(org.jdesk top.layout.GroupLayout.BASELINE)
.add(lblClientName)
.add(txtClientName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
.add(ClientTabLayout.createParallelGroup(org.jdesk top.layout.GroupLayout.BASELINE)
.add(lblClientSurname)
.add(txtClientSurname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(btnClientAdd))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 66, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.R ELATED)
.add(ClientTabLayout.createParallelGroup(org.jdesk top.layout.GroupLayout.LEADING)
.add(lblClientType)
.add(choClientType, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(21, 21, 21))
);

HotelPanes.addTab("tab1", ClientTab);

org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.Gro upLayout.LEADING)
.add(HotelPanes, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 420, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.Gro upLayout.LEADING)
.add(HotelPanes, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 323, Short.MAX_VALUE)
);

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

private void btnClientAddMouseClicked(java.awt.event.MouseEvent evt) {
DBRoutines db = new DBRoutines("ftp.mcast.edu.mt", "gerards", "gerards", "***");
db.connect();
String clientInsert = "INSERT INTO apfclients (ClientID,Name,Surname,Address,Telephone,Mobile,Ty pe,Treatment) VALUE (?,?,?,?,?,?,?,?)";
PreparedStatement sqlStatement = null;

try {
sqlStatement = db.dbConnection.prepareStatement(clientInsert);
sqlStatement.setString(1, txtClientId.getText());
sqlStatement.setString(2, txtClientName.getText());
sqlStatement.setString(3, txtClientSurname.getText());
sqlStatement.setString(4, txtClientAddress.getText());
sqlStatement.setString(5, txtClientTel.getText());
sqlStatement.setString(6, txtClientMobile.getText());
sqlStatement.setString(7, choClientType.getSelectedItem());

if (choClientType.getSelectedItem().equals("VIP")) {
sqlStatement.setString(8,"Wifi, Sweets, Champagne");
} else if (choClientType.getSelectedItem().equals("Family")) {
sqlStatement.setString(8,"Sweets");
} else if (choClientType.getSelectedItem().equals("Couple")) {
sqlStatement.setString(8,"Champagne");
} else if (choClientType.getSelectedItem().equals("Business" )) {
sqlStatement.setString(8,"Wifi");
} else {
sqlStatement.setString(8,"null");
}
sqlStatement.executeUpdate();

JOptionPane.showMessageDialog(null, "Client has been successfully added!");
} catch (SQLException ex) {
ex.printStackTrace();
}
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new HotelGUI().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.JPanel ClientTab;
private javax.swing.JTabbedPane HotelPanes;
private javax.swing.JButton btnClientAdd;
private java.awt.Choice choClientType;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lblClientAddress;
private javax.swing.JLabel lblClientId;
private javax.swing.JLabel lblClientMobile;
private javax.swing.JLabel lblClientName;
private javax.swing.JLabel lblClientSurname;
private javax.swing.JLabel lblClientTelephone;
private javax.swing.JLabel lblClientType;
private javax.swing.JEditorPane txtClientAddress;
private javax.swing.JTextField txtClientId;
private javax.swing.JTextField txtClientMobile;
private javax.swing.JTextField txtClientName;
private javax.swing.JTextField txtClientSurname;
private javax.swing.JTextField txtClientTel;
// End of variables declaration

}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help needed!!! :S mark-mlt Networking 1 04-14-2008 10:27 AM
Help Needed pks New To Java 1 01-09-2008 01:07 AM
Uni Project - GUI - Help Needed deeadeed New To Java 0 12-04-2007 12:10 AM
help needed. dirtycash New To Java 3 12-03-2007 10:17 PM
jfreeReport help needed sandor XML 1 04-20-2007 09:10 PM


All times are GMT +3. The time now is 05:47 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org