Tengo un problema con este codigo:
CÓDIGO
package restaurante2;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.SQLException;
//import.java.util.*;
public class Registro extends javax.swing.JFrame {
public Registro() {
initComponents();
this.setLocationRelativeTo(null);
}
public class Conexion {
public Connection getConnection() throws Exception {
String servidor="127.0.0.1:8080";
String user="system";
String pass="2100";
String driver="oracle.jdb.driver.OracleDiver";
Class.forName("oracle.jdbc.OracleDriver");
Connection conexion=DriverManager.getConnection("127.0.0.1:8080,restaurante,2100");
return conexion;
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabelNumOrden = new javax.swing.JLabel();
jLabelCliente = new javax.swing.JLabel();
jLabelPlatillo = new javax.swing.JLabel();
jTextNumOrden = new javax.swing.JTextField();
jTextFieldCliente = new javax.swing.JTextField();
jTextFieldPlatillo = new javax.swing.JTextField();
Alta = new javax.swing.JButton();
Baja = new javax.swing.JButton();
Editar = new javax.swing.JButton();
jButtonSAL = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabelNumOrden.setText("NumOrden");
jLabelCliente.setText("Cliente");
jLabelPlatillo.setText("Platillo");
jTextNumOrden.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
jTextNumOrdenKeyTyped(evt);
}
});
jTextFieldCliente.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextFieldClienteActionPerformed(evt);
}
});
jTextFieldCliente.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
jTextFieldClienteKeyTyped(evt);
}
});
Alta.setText("Alta");
Alta.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
AltaActionPerformed(evt);
}
});
Baja.setText("Baja");
Baja.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BajaActionPerformed(evt);
}
});
Editar.setText("Editar");
Editar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
EditarActionPerformed(evt);
}
});
jButtonSAL.setText("X");
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(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabelPlatillo)
.addComponent(jLabelCliente)
.addComponent(jLabelNumOrden))
.addGap(27, 27, 27)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextFieldCliente, javax.swing.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE)
.addComponent(jTextNumOrden)
.addComponent(jTextFieldPlatillo))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonSAL))
.addGroup(layout.createSequentialGroup()
.addContainerGap(58, Short.MAX_VALUE)
.addComponent(Alta)
.addGap(44, 44, 44)
.addComponent(Baja)
.addGap(52, 52, 52)
.addComponent(Editar)
.addGap(81, 81, 81))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabelNumOrden)
.addComponent(jTextNumOrden, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(39, 39, 39)
.addComponent(jLabelCliente))
.addComponent(jTextFieldCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jButtonSAL))
.addGap(37, 37, 37)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabelPlatillo)
.addComponent(jTextFieldPlatillo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 72, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Alta)
.addComponent(Baja)
.addComponent(Editar))
.addGap(53, 53, 53))
);
pack();
}// </editor-fold>
private void AltaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void BajaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void EditarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jTextNumOrdenKeyTyped(java.awt.event.KeyEvent evt) {
char c= evt.getKeyChar();
if (Character.isLetter(c)) {
getToolkit().beep();
evt.consume();
}
}
private void jTextFieldClienteActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jTextFieldClienteKeyTyped(java.awt.event.KeyEvent evt) {
//evento envocado
char c=evt.getKeyChar();
//convertimos char la tecla pulsada
if(Character.isDigit(c)) {
//pregunta si es digito
getToolkit().beep();
//alerta
evt.consume();
//bloquea
Error.setText("Solo letras");
}
}
public static void main(String []args) throws Exception {
String jTextFieldCliente = null;
String jTextFieldPlatillo = null;
int jTextNumOrden = 0;
Connection con = null;
PreparedStatement pstmt = null;
String sql = null;
try{
con=DriverManager.getConnection("127.0.0.1:8080,restaurante,2100");
String query = "insert into menu (numorden,cliente,platillo)values(?,?,?)";
pstmt = con.prepareStatement(query);
pstmt.setInt(1, jTextNumOrden);
pstmt.setString(2,jTextFieldCliente);
pstmt.setString(3, jTextFieldPlatillo);
pstmt.executeUpdate();
}catch (Exception e){
e.printStackTrace();
}finally {
pstmt.close();
con.close();
}
}
public static void Update(){
String jTextFieldCliente = null;
String jTextFieldPlatillo = null;
int jTextNumOrden = 0;
Connection con = null;
PreparedStatement pstmt = null;
String sql = null;
try{
con=DriverManager.getConnection("127.0.0.1:8080,restaurante , 2100");
String query = "delete from menu where (numorden = ?,cliente = ? and platillo =?)";
pstmt = con.prepareStatement(query);
pstmt.setInt(1, jTextNumOrden);
pstmt.setString(2,jTextFieldCliente);
pstmt.setString(3, jTextFieldPlatillo);
pstmt.executeUpdate();
}catch (Exception e){
e.printStackTrace();
}finally {
pstmt.close();
con.close();
}
}
public static void Delete(){
String jTextFieldCliente = null;
String jTextFieldPlatillo = null;
int jTextNumOrden = 0;
Connection con = null;
PreparedStatement pstmt = null;
String sql = null;
try{
con=DriverManager.getConnection("127.0.0.1:8080,restaurante , 2100");
String query = "de into menu (numorden,cliente,platillo)values(?,?,?)";
pstmt = con.prepareStatement(query);
pstmt.setInt(1, jTextNumOrden);
pstmt.setString(2,jTextFieldCliente);
pstmt.setString(3, jTextFieldPlatillo);
pstmt.executeUpdate();
}catch (Exception e){
e.printStackTrace();
}finally {
pstmt.close();
con.close();
}
}
// Variables declaration - do not modify
private javax.swing.JButton Alta;
private javax.swing.JButton Baja;
private javax.swing.JButton Editar;
private javax.swing.JButton jButtonSAL;
private javax.swing.JLabel jLabelCliente;
private javax.swing.JLabel jLabelNumOrden;
private javax.swing.JLabel jLabelPlatillo;
private javax.swing.JTextField jTextFieldCliente;
private javax.swing.JTextField jTextFieldPlatillo;
private javax.swing.JTextField jTextNumOrden;
// End of variables declaration
}
Arroja el siguiente error
java.sql.SQLException: No suitable driver found for 127.0.0.1:8080,restaurante,2100
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at restaurante2.Registro.main(Registro.java:204)
Exception in thread "main" java.lang.NullPointerException
at restaurante2.Registro.main(Registro.java:214)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
off topic : perdi acceso a mi cuenta anterior, tenia mucha reputacion, esto lo aclaro para dejar en claro que no soy un noob que solo busca que le solucionen un problema, tambien aporte en su tiempo, este era mi usuario https://stackoverflow.com/users/209797/agelessessence