Advertisement
Hassnsy

Problem

May 23rd, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.09 KB | None | 0 0
  1. اسثاذي انا طبقت مثلك تمام بس يفتح البرنامج + بس حط ااسم المستخدم و كلمة المرور يعطيني هي الرسالة
  2. java.sql.sqlexception no such table
  3. ======================================
  4. كود الاتصال
  5. ======================================
  6.  
  7. /*
  8. * To change this license header, choose License Headers in Project Properties.
  9. * To change this template file, choose Tools | Templates
  10. * and open the template in the editor.
  11. */
  12. package app;
  13.  
  14. import java.sql.*;
  15. import javax.swing.*;
  16.  
  17. public class ConnectDB {
  18.  
  19. public static Connection connect() {
  20.  
  21. try {
  22. Class.forName("org.sqlite.JDBC");
  23.  
  24. Connection con = DriverManager.getConnection( "jdbc:sqlite:D:\\Program\\over.db" );
  25. JOptionPane.showMessageDialog(null, "connected");
  26. return con;
  27. } catch (Exception e) {
  28. JOptionPane.showMessageDialog(null, "cant connect to database");
  29. }
  30. return null;
  31. }
  32.  
  33. public static void main(String[] args) {
  34. ConnectDB.connect();
  35.  
  36. }
  37.  
  38. }
  39. ===================================
  40. كود الفورم
  41. ===================================
  42. /*
  43. * To change this license header, choose License Headers in Project Properties.
  44. * To change this template file, choose Tools | Templates
  45. * and open the template in the editor.
  46. */
  47. package app;
  48.  
  49.  
  50. import java.sql.*;
  51. import javax.swing.JOptionPane;
  52.  
  53. /**
  54. *
  55. * @author s 7 s
  56. */
  57. public class cack extends javax.swing.JFrame {
  58.  
  59. Connection con = null;
  60. PreparedStatement pst = null;
  61. ResultSet rs = null;
  62.  
  63. public cack() {
  64. initComponents();
  65. this.setLocationRelativeTo(null);
  66. con = ConnectDB.connect();
  67. }
  68.  
  69. /**
  70. * This method is called from within the constructor to initialize the form.
  71. * WARNING: Do NOT modify this code. The content of this method is always
  72. * regenerated by the Form Editor.
  73. */
  74. @SuppressWarnings("unchecked")
  75. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  76. private void initComponents() {
  77.  
  78. jPanel1 = new javax.swing.JPanel();
  79. jButton1 = new javax.swing.JButton();
  80. jButton2 = new javax.swing.JButton();
  81. password = new javax.swing.JTextField();
  82. jLabel2 = new javax.swing.JLabel();
  83. username = new javax.swing.JTextField();
  84. jLabel1 = new javax.swing.JLabel();
  85. jButton3 = new javax.swing.JButton();
  86.  
  87. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  88. setTitle("Welcum Bro");
  89. setBackground(new java.awt.Color(24, 99, 72));
  90. setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
  91. setResizable(false);
  92.  
  93. 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
  94.  
  95. jButton1.setText("Sing up");
  96. jButton1.setMaximumSize(new java.awt.Dimension(51, 23));
  97. jButton1.setMinimumSize(new java.awt.Dimension(51, 23));
  98. jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
  99. public void mouseClicked(java.awt.event.MouseEvent evt) {
  100. jButton1MouseClicked(evt);
  101. }
  102. });
  103. jButton1.addActionListener(new java.awt.event.ActionListener() {
  104. public void actionPerformed(java.awt.event.ActionEvent evt) {
  105. jButton1ActionPerformed(evt);
  106. }
  107. });
  108.  
  109. jButton2.setText("Exit");
  110. jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
  111. public void mouseClicked(java.awt.event.MouseEvent evt) {
  112. jButton2MouseClicked(evt);
  113. }
  114. });
  115.  
  116. password.addMouseListener(new java.awt.event.MouseAdapter() {
  117. public void mouseClicked(java.awt.event.MouseEvent evt) {
  118. passwordMouseClicked(evt);
  119. }
  120. });
  121. password.addActionListener(new java.awt.event.ActionListener() {
  122. public void actionPerformed(java.awt.event.ActionEvent evt) {
  123. passwordActionPerformed(evt);
  124. }
  125. });
  126.  
  127. jLabel2.setText(" PassWord :");
  128.  
  129. username.setToolTipText("");
  130. username.addMouseListener(new java.awt.event.MouseAdapter() {
  131. public void mouseClicked(java.awt.event.MouseEvent evt) {
  132. usernameMouseClicked(evt);
  133. }
  134. });
  135. username.addActionListener(new java.awt.event.ActionListener() {
  136. public void actionPerformed(java.awt.event.ActionEvent evt) {
  137. usernameActionPerformed(evt);
  138. }
  139. });
  140.  
  141. jLabel1.setText(" UserName :");
  142.  
  143. jButton3.setText("Log in");
  144. jButton3.addActionListener(new java.awt.event.ActionListener() {
  145. public void actionPerformed(java.awt.event.ActionEvent evt) {
  146. jButton3ActionPerformed(evt);
  147. }
  148. });
  149.  
  150. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  151. jPanel1.setLayout(jPanel1Layout);
  152. jPanel1Layout.setHorizontalGroup(
  153. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  154. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
  155. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  156. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE)
  157. .addComponent(jButton3)
  158. .addGap(52, 52, 52)
  159. .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
  160. .addGroup(jPanel1Layout.createSequentialGroup()
  161. .addContainerGap()
  162. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  163. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  164. .addComponent(password, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)
  165. .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
  166. .addComponent(username))
  167. .addComponent(jLabel1))
  168. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  169. );
  170. jPanel1Layout.setVerticalGroup(
  171. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  172. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
  173. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  174. .addComponent(jLabel1)
  175. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  176. .addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  177. .addGap(18, 18, 18)
  178. .addComponent(jLabel2)
  179. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  180. .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  181. .addGap(18, 18, 18)
  182. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  183. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  184. .addComponent(jButton2)
  185. .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
  186. .addGap(4, 4, 4))
  187. );
  188.  
  189. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  190. getContentPane().setLayout(layout);
  191. layout.setHorizontalGroup(
  192. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  193. .addGroup(layout.createSequentialGroup()
  194. .addContainerGap()
  195. .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  196. .addContainerGap())
  197. );
  198. layout.setVerticalGroup(
  199. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  200. .addGroup(layout.createSequentialGroup()
  201. .addContainerGap()
  202. .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  203. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  204. );
  205.  
  206. pack();
  207. }// </editor-fold>
  208.  
  209. private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
  210.  
  211. dispose();
  212. }
  213.  
  214. private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {
  215. dispose();
  216. }
  217.  
  218. private void usernameMouseClicked(java.awt.event.MouseEvent evt) {
  219. username.setText("");
  220. }
  221.  
  222. private void passwordActionPerformed(java.awt.event.ActionEvent evt) {
  223. password.setText("");
  224. }
  225.  
  226. private void passwordMouseClicked(java.awt.event.MouseEvent evt) {
  227. password.setText("");
  228. }
  229.  
  230. private void usernameActionPerformed(java.awt.event.ActionEvent evt) {
  231. // TODO add your handling code here:
  232. }
  233.  
  234. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  235. String uso = "s7s";
  236. String pao = "123456";
  237. String u = username.getText();
  238. String p = password.getText();
  239. if (uso.equals(u) && pao.equals(p)) {
  240. new wlc().setVisible(true);
  241. } else {
  242. JOptionPane.showMessageDialog(jButton1, "you can't make a new user if you are not a user !!");
  243. }
  244.  
  245.  
  246. }
  247.  
  248. private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
  249.  
  250. try {
  251. String qurr = " select * from empo where username=? and password=? ";
  252. pst = con.prepareStatement(qurr);
  253. pst.setString(1, username.getText());
  254. pst.setString(2, password.getText());
  255. rs = pst.executeQuery();
  256. if (rs.next()) {
  257. new wlc2().setVisible(true);
  258. dispose();
  259. } else {
  260. JOptionPane.showMessageDialog(this, "UserName OR PassWord is INcorrect");
  261. }
  262.  
  263. } catch (Exception e) {
  264. JOptionPane.showMessageDialog(this, e);
  265.  
  266. }
  267.  
  268.  
  269. }
  270.  
  271. /**
  272. * @param args the command line arguments
  273. */
  274. public static void main(String args[]) {
  275. /* Set the Nimbus look and feel */
  276. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  277. /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  278. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  279. */
  280. try {
  281. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  282. if ("Nimbus".equals(info.getName())) {
  283. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  284. break;
  285. }
  286. }
  287. } catch (ClassNotFoundException ex) {
  288. java.util.logging.Logger.getLogger(cack.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  289. } catch (InstantiationException ex) {
  290. java.util.logging.Logger.getLogger(cack.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  291. } catch (IllegalAccessException ex) {
  292. java.util.logging.Logger.getLogger(cack.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  293. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  294. java.util.logging.Logger.getLogger(cack.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  295. }
  296. //</editor-fold>
  297.  
  298. /* Create and display the form */
  299. java.awt.EventQueue.invokeLater(() -> {
  300. new cack().setVisible(true);
  301. });
  302. }
  303.  
  304. // Variables declaration - do not modify
  305. private javax.swing.JButton jButton1;
  306. private javax.swing.JButton jButton2;
  307. private javax.swing.JButton jButton3;
  308. private javax.swing.JLabel jLabel1;
  309. private javax.swing.JLabel jLabel2;
  310. private javax.swing.JPanel jPanel1;
  311. private javax.swing.JTextField password;
  312. private javax.swing.JTextField username;
  313. // End of variables declaration
  314. }
  315. =====================================
  316. شو الحل صديقي ؟
  317. طبعاً
  318. بكود الاتصال
  319. Connection con = DriverManager.getConnection( "jdbc:sqlite:D:\\Program\\over.db" );
  320. هاد الكود وقت ساويه
  321. Connection con = DriverManager.getConnection( "jdbc:sqlite:D:\\Program\\over.sql" );
  322. يعطيني مشكلة
  323. java.sql.sqlexception file is encrypted or is not a database
  324. =====================================
  325. ممكن حل سريع
  326. ؟؟
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement