Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- اسثاذي انا طبقت مثلك تمام بس يفتح البرنامج + بس حط ااسم المستخدم و كلمة المرور يعطيني هي الرسالة
- java.sql.sqlexception no such table
- ======================================
- كود الاتصال
- ======================================
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package app;
- import java.sql.*;
- import javax.swing.*;
- public class ConnectDB {
- public static Connection connect() {
- try {
- Class.forName("org.sqlite.JDBC");
- Connection con = DriverManager.getConnection( "jdbc:sqlite:D:\\Program\\over.db" );
- JOptionPane.showMessageDialog(null, "connected");
- return con;
- } catch (Exception e) {
- JOptionPane.showMessageDialog(null, "cant connect to database");
- }
- return null;
- }
- public static void main(String[] args) {
- ConnectDB.connect();
- }
- }
- ===================================
- كود الفورم
- ===================================
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package app;
- import java.sql.*;
- import javax.swing.JOptionPane;
- /**
- *
- * @author s 7 s
- */
- public class cack extends javax.swing.JFrame {
- Connection con = null;
- PreparedStatement pst = null;
- ResultSet rs = null;
- public cack() {
- initComponents();
- this.setLocationRelativeTo(null);
- con = ConnectDB.connect();
- }
- /**
- * 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() {
- jPanel1 = new javax.swing.JPanel();
- jButton1 = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
- password = new javax.swing.JTextField();
- jLabel2 = new javax.swing.JLabel();
- username = new javax.swing.JTextField();
- jLabel1 = new javax.swing.JLabel();
- jButton3 = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- setTitle("Welcum Bro");
- setBackground(new java.awt.Color(24, 99, 72));
- setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
- setResizable(false);
- jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Login", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Tahoma", 0, 36), new java.awt.Color(0, 0, 255))); // NOI18N
- jButton1.setText("Sing up");
- jButton1.setMaximumSize(new java.awt.Dimension(51, 23));
- jButton1.setMinimumSize(new java.awt.Dimension(51, 23));
- jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mouseClicked(java.awt.event.MouseEvent evt) {
- jButton1MouseClicked(evt);
- }
- });
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- jButton2.setText("Exit");
- jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mouseClicked(java.awt.event.MouseEvent evt) {
- jButton2MouseClicked(evt);
- }
- });
- password.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mouseClicked(java.awt.event.MouseEvent evt) {
- passwordMouseClicked(evt);
- }
- });
- password.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- passwordActionPerformed(evt);
- }
- });
- jLabel2.setText(" PassWord :");
- username.setToolTipText("");
- username.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mouseClicked(java.awt.event.MouseEvent evt) {
- usernameMouseClicked(evt);
- }
- });
- username.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- usernameActionPerformed(evt);
- }
- });
- jLabel1.setText(" UserName :");
- jButton3.setText("Log in");
- jButton3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton3ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE)
- .addComponent(jButton3)
- .addGap(52, 52, 52)
- .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(password, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(username))
- .addComponent(jLabel1))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jLabel1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addComponent(jLabel2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(18, 18, 18)
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jButton2)
- .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(4, 4, 4))
- );
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
- pack();
- }// </editor-fold>
- private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
- dispose();
- }
- private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {
- dispose();
- }
- private void usernameMouseClicked(java.awt.event.MouseEvent evt) {
- username.setText("");
- }
- private void passwordActionPerformed(java.awt.event.ActionEvent evt) {
- password.setText("");
- }
- private void passwordMouseClicked(java.awt.event.MouseEvent evt) {
- password.setText("");
- }
- private void usernameActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- }
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- String uso = "s7s";
- String pao = "123456";
- String u = username.getText();
- String p = password.getText();
- if (uso.equals(u) && pao.equals(p)) {
- new wlc().setVisible(true);
- } else {
- JOptionPane.showMessageDialog(jButton1, "you can't make a new user if you are not a user !!");
- }
- }
- private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- String qurr = " select * from empo where username=? and password=? ";
- pst = con.prepareStatement(qurr);
- pst.setString(1, username.getText());
- pst.setString(2, password.getText());
- rs = pst.executeQuery();
- if (rs.next()) {
- new wlc2().setVisible(true);
- dispose();
- } else {
- JOptionPane.showMessageDialog(this, "UserName OR PassWord is INcorrect");
- }
- } catch (Exception e) {
- JOptionPane.showMessageDialog(this, e);
- }
- }
- /**
- * @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 http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(cack.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(cack.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(cack.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(cack.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(() -> {
- new cack().setVisible(true);
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JTextField password;
- private javax.swing.JTextField username;
- // End of variables declaration
- }
- =====================================
- شو الحل صديقي ؟
- طبعاً
- بكود الاتصال
- Connection con = DriverManager.getConnection( "jdbc:sqlite:D:\\Program\\over.db" );
- هاد الكود وقت ساويه
- Connection con = DriverManager.getConnection( "jdbc:sqlite:D:\\Program\\over.sql" );
- يعطيني مشكلة
- java.sql.sqlexception file is encrypted or is not a database
- =====================================
- ممكن حل سريع
- ؟؟
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement