miren lo que estoy realizando es una simple ventana de login que jale de la bd el nombre y password, pero me sale el error SQLException: Column not found siendo q si existe aqui pongo el codigo para ver si me pueden ayudar a encontrar cual es la falla
Código PHP:
import javax.swing.*;
import java.sql.*;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Rectangle;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class AccessBD implements ActionListener{
private Connection c;
private JFrame frame;
private JTextField user;
private JButton button;
private GridBagLayout layout;
private GridBagConstraints gbc;
private JLabel label;
private JPasswordField pass;
private Statement st;
private ResultSet rs;
private DatabaseMetaData metadata;
private String statement;
String id = "Alberto";
String passw = "otreblax";
ResultSet result = null;
public AccessBD(){
layout =new GridBagLayout();
gbc = new GridBagConstraints ();
frame = new JFrame("Conectar");
frame.setSize (300,250);
Rectangle screenRect = frame.getGraphicsConfiguration().getBounds();
frame.setLocation(
screenRect.x + screenRect.width/2 - frame.getSize().width/2,
screenRect.y + screenRect.height/2 - frame.getSize().height/2);
frame.getContentPane ().setLayout (layout);
init();
frame.setResizable (false);
frame.setVisible (true);
}
private void init(){
gbc.gridwidth = gbc.RELATIVE;
gbc.insets = new Insets (5,5,5,5);
label = new JLabel("usuario:");
layout.setConstraints (label,gbc);
frame.getContentPane ().add (label);
layout.setConstraints (label,gbc);
gbc.gridwidth = gbc.REMAINDER;
gbc.insets = new Insets (5,5,5,5);
user = new JTextField (12);
layout.setConstraints (user,gbc);
frame.getContentPane ().add (user);
gbc.gridwidth = gbc.RELATIVE;
gbc.insets = new Insets (5,5,5,5);
label = new JLabel ("password:");
layout.setConstraints (label,gbc);
frame.getContentPane ().add (label);
layout.setConstraints (label,gbc);
gbc.gridwidth = gbc.REMAINDER;
gbc.insets = new Insets (5,5,5,5);
pass = new JPasswordField (12);
layout.setConstraints (pass,gbc);
frame.getContentPane ().add (pass);
gbc.gridwidth = gbc.RELATIVE;
gbc.insets = new Insets (5,5,5,5);
button = new JButton ("Conectar");
button.addActionListener (this);
layout.setConstraints (button,gbc);
frame.getContentPane ().add (button);
layout.setConstraints (button,gbc);
gbc.gridwidth = gbc.REMAINDER;
gbc.insets = new Insets (5,5,5,5);
button = new JButton ("Cancelar");
button.addActionListener (this);
layout.setConstraints (button,gbc);
frame.getContentPane ().add (button);
layout.setConstraints (button,gbc);
}
public void actionPerformed(ActionEvent ae){
if(ae.getActionCommand ().equals ("Conectar")){
try{
String usu="", pas="";
String url = "jdbc:odbc:Usuarios";
String query = "SELECT nom_usu FROM Usuario";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c = DriverManager.getConnection(url,id,passw);
c.setAutoCommit(false);
usu=user.getText ();
pas= pass.getText ();
st=c.createStatement ();
result = st.executeQuery(query );//("SELECT nom_usu FROM Usuario");
String nombre = result.getString("Usuario");
System.out.println(nombre);
if(usu==nombre){
System.out.println("Nombre correcto");
//Ir a la siguiente ventana
}
else{
System.out.println("Nombre Incorrecto");
}
// frame.dispose ();
}catch(SQLException es){
System.out.println("Sql " +es);
System.out.println("error query"+es);
}catch(ClassNotFoundException nfe){
System.out.println("Sql " +nfe);
nfe.printStackTrace ();
}
}else{
frame.dispose();
}
}
public static void main(String []args){
AccessBD abd= new AccessBD();
abd.init();
}
}
sinceramente no se que es lo q pasa