http://www.highscore.de/java/aufbau/datenbank.html#section6
http://www.galileocomputing.de/open...sel20_004.htm#Rxx747java20004040008311F037118
http://www.galileocomputing.de/open...sel20_004.htm#Rxx747java20004040008311F037118
habe mir das durchgelesen, dennoch hab ich keinen Plan und bekomme immer die Meldung:
der Code selber ist in ordnung da er schon woanders in netzwerk in der Schule lief, doch bei mir zuhause gehts net...
zur info:
H:\Java Projekt Datenbank
hier liegt die .mdb access datenbank!
im gleichen verzeichnis wie die .java dateien...
http://www.galileocomputing.de/open...sel20_004.htm#Rxx747java20004040008311F037118
http://www.galileocomputing.de/open...sel20_004.htm#Rxx747java20004040008311F037118
habe mir das durchgelesen, dennoch hab ich keinen Plan und bekomme immer die Meldung:
Code:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Der Datenquellenname wurde nicht gefunden, und es wurde kein Standardtreiber angegeben
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at login.connectDB(login.java:122)
at login.<init>(login.java:112)
at login.main(login.java:251)
der Code selber ist in ordnung da er schon woanders in netzwerk in der Schule lief, doch bei mir zuhause gehts net...
Code:
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
public class login extends JFrame
{
private JPanel jPanel12;
private JLabel statusMsgLB;
private JLabel statusLB;
private JButton abbr;
private JButton ok;
private JLabel login;
private JPasswordField passein;
private JComboBox statusein;
private JTextField nameein;
private JLabel account;
private JLabel passwort;
private JLabel name;
private JPanel eingabe;
private AdminZugriff adminPanel;
private LehrerZugriff lehrerPanel;
private SchülerZugriff schülerPanel;
static Connection con;
static Statement sqlAnweisung;
static ResultSet result;
static String sqlzeile;
static String nameeinErgebnis;
static String passwortErgebnis;
static String sqlname;
static String sqlpasswort;
public login()
{
super();
try
{
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel");
}
catch(Exception e)
{
e.printStackTrace();
}
//setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setLayout(null);
login = new JLabel();
statusMsgLB = new JLabel();
name = new JLabel();
nameein = new JTextField();
passwort = new JLabel();
passein = new JPasswordField();
account = new JLabel();
statusein = new JComboBox();
ok = new JButton();
abbr = new JButton();
statusLB = new JLabel();
add(nameein);
add(name);
add(passein);
add(statusein);
add(statusMsgLB);
add(account);
add(passwort);
add(login);
add(ok);
add(statusLB);
add(abbr);
nameein.setBounds(20,20,100,30);
name.setBounds(120,20,100,30);
passein.setBounds(20,60,100,30);
statusein.setBounds(120,60,100,30);
statusMsgLB.setBounds(20,20,100,30);
account.setBounds(20,20,100,30);
passwort.setBounds(20,20,100,30);
login.setBounds(20,20,100,30);
ok.setBounds(20,20,100,30);
statusLB.setBounds(20,20,100,30);
abbr.setBounds(20,20,100,30);
passwort.setText("Passwort:");
account.setText("Account:");
passwort.setText("Passwort:");
name.setText("Name:");
statusMsgLB.setText("Alles OK");
login.setText("Bitte Loggen Sie sich ein:");
abbr.setText("Abbrechen");
statusLB.setText("Status:");
ok.setText("OK");
ComboBoxModel statuseinModel = new DefaultComboBoxModel(new String[] { "Schüler", "Lehrer", "Admin" });
ok.addActionListener(new ButLog());
abbr.addActionListener(new ButLog());
try
{
connectDB();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void connectDB() throws ClassNotFoundException, SQLException
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:fda","",""); // fda habe ich den dns namen genannt...
// was ich unter windows-systemsteuerung eingestellt habe bei odbc
//con=DriverManager.getConnection("jdbc:odbc:AccessQuelle","","");
}
public void passPruefen ()
{
}
class ButLog implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String pass,name;
if (e.getSource().equals(ok))
{
nameeinErgebnis = nameein.getText();
passwortErgebnis = passein.getText();
//passwortErgebnis = (passein.getPassword()).toString();
//---------------------------------- Schüler Account Abrage ---------------------------------------//
if (statusein.getSelectedItem().toString().equals("Schüler"))
{
try
{
sqlname = "Select * from LoginSchueler where Name = '"+nameeinErgebnis+"'";
sqlAnweisung=con.createStatement();
result = sqlAnweisung.executeQuery(sqlname);
result.next();
name = result.getString("Name");
pass = result.getString("Passwort");
result.close();
if (nameeinErgebnis.equals(name) && passwortErgebnis.equals(pass))
{
schülerPanel = new SchülerZugriff();
}
else
{
statusMsgLB.setText("Password/User existiert nicht");
}
}
catch (SQLException a)
{
a.printStackTrace();
}
}
//------------------------------------- Lehrer Account Abfrage ------------------------------------//
if (statusein.getSelectedItem().toString().equals("Lehrer"));
{
try
{
sqlname = "Select * from LoginLehrer where Name = '"+nameeinErgebnis+"'";
sqlAnweisung=con.createStatement();
result = sqlAnweisung.executeQuery(sqlname);
result.next();
name = result.getString("Name");
pass = result.getString("Passwort");
result.close();
if (nameeinErgebnis.equals(name) && passwortErgebnis.equals(pass))
{
lehrerPanel = new LehrerZugriff();
}
else
{
statusMsgLB.setText("Password/User existiert nicht");
}
}
catch (SQLException a)
{
a.printStackTrace();
}
}
//------------------------------------- Admin Account Abfrage -------------------------------------//
if (statusein.getSelectedItem().toString().equals("Admin"));
{
try
{
sqlname = "Select * from LoginAdmin where Name = '"+nameeinErgebnis+"'";
sqlAnweisung=con.createStatement();
result = sqlAnweisung.executeQuery(sqlname);
result.next();
name = result.getString("Name");
pass = result.getString("Passwort");
result.close();
if (nameeinErgebnis.equals(name) && passwortErgebnis.equals(pass))
{
adminPanel = new AdminZugriff();
}
else
{
statusMsgLB.setText("Password/User existiert nicht");
}
}
catch (SQLException a)
{
a.printStackTrace();
}
}
//--------------------------------------- Login Abbrechen ---------------------------------------//
if (e.getSource().equals(abbr))
{
try
{
System.exit(0);
}
catch (Exception a)
{
a.printStackTrace();
}
}
//---------------------------------- Ende Login Abbrechen ---------------------------------------//
}
}
}
public static void main(String[] args) //throws ClassNotFoundException, SQLException
{
login inst = new login();
inst.setSize(600,400);
inst.setLocation(300,200);
inst.setVisible(true);
}
}
zur info:
H:\Java Projekt Datenbank
hier liegt die .mdb access datenbank!
im gleichen verzeichnis wie die .java dateien...