?? studentview.java
字號(hào):
politics=rs.getFloat("politics"); algebra=rs.getFloat("algebra"); probability=rs.getFloat("probability"); logic=rs.getFloat("logic"); Object temp1[]={id,name,math,english,politics,algebra,probability,logic}; jTableabc.addRow(temp1); } rs.close(); stmt.close(); con.close(); } catch(Exception e){e.printStackTrace();} }//GEN-LAST:event_jButton2ActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed int temp1;Float temp2;String temp3; temp3=jTextField18.getText(); temp2=Float.parseFloat(temp3); if(jTextField17.getText().equals("")){ JOptionPane.showMessageDialog(null,"學(xué)號(hào)不能為空"); }else{ temp1=jComboBox1.getSelectedIndex(); try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=denghan","sa",""); Statement stmt =con.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs=null; String ID=jTextField17.getText(); rs=stmt.executeQuery( "SELECT * FROM new WHERE id="+ID); rs.last(); switch(temp1){ case 0: rs.updateString("math", temp3); break; case 1: rs.updateString("English", temp3); break; case 2: rs.updateString("politics", temp3); break; case 3: rs.updateString("algebra", temp3); break; case 4: rs.updateString("probability", temp3); break; case 5: rs.updateString("logic", temp3); break; } rs.updateRow(); JOptionPane.showMessageDialog(null, "修改成功", "修改", JOptionPane.INFORMATION_MESSAGE); rs.close(); stmt.close(); con.close(); } catch(Exception ee){ ee.printStackTrace(); } DefaultTableModel jTableabc=(DefaultTableModel)jTable1.getModel(); jTableabc.setRowCount(0); try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=denghan","sa",""); Statement stmt =con.createStatement(); String in="insert into new"; //stmt.executeUpdate(in); ResultSet rs =stmt.executeQuery("select * from new"); while (rs.next()){ id=rs.getString("id"); name=rs.getString("name"); math=rs.getFloat("math"); english=rs.getFloat("English"); politics=rs.getFloat("politics"); algebra=rs.getFloat("algebra"); probability=rs.getFloat("probability"); logic=rs.getFloat("logic"); Object temp[]={id,name,math,english,politics,algebra,probability,logic}; jTableabc.addRow(temp); } rs.close(); // stmt.close(); con.close(); }catch(Exception e){ e.printStackTrace(); } } }//GEN-LAST:event_jButton3ActionPerformed private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed // TODO add your handling code here: System.exit(0); }//GEN-LAST:event_exitMenuItemActionPerformed private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed DefaultTableModel jTableabc=(DefaultTableModel)jTable1.getModel(); jTableabc.setRowCount(0); try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=denghan","sa",""); Statement stmt = con.createStatement(); ResultSet rs =stmt.executeQuery("select * from new order by id"); while (rs.next()){ id=rs.getString("id"); name=rs.getString("name"); math=rs.getFloat("math"); english=rs.getFloat("English"); politics=rs.getFloat("politics"); algebra=rs.getFloat("algebra"); probability=rs.getFloat("probability"); logic=rs.getFloat("logic"); Object temp1[]={id,name,math,english,politics,algebra,probability,logic}; jTableabc.addRow(temp1); } rs.close(); stmt.close(); con.close(); } catch(Exception e){e.printStackTrace();} }//GEN-LAST:event_jMenuItem4ActionPerformed private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed DefaultTableModel jTableabc=(DefaultTableModel)jTable1.getModel(); jTableabc.setRowCount(0); try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=denghan","sa",""); Statement stmt = con.createStatement(); ResultSet rs =stmt.executeQuery("select * from new order by math desc"); while (rs.next()){ id=rs.getString("id"); name=rs.getString("name"); math=rs.getFloat("math"); english=rs.getFloat("English"); politics=rs.getFloat("politics"); algebra=rs.getFloat("algebra"); probability=rs.getFloat("probability"); logic=rs.getFloat("logic"); Object temp1[]={id,name,math,english,politics,algebra,probability,logic}; jTableabc.addRow(temp1); } rs.close(); stmt.close(); con.close(); } catch(Exception e){e.printStackTrace();} }//GEN-LAST:event_jMenuItem5ActionPerformed private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed DefaultTableModel jTableabc=(DefaultTableModel)jTable1.getModel(); jTableabc.setRowCount(0); try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=denghan","sa",""); Statement stmt = con.createStatement(); ResultSet rs =stmt.executeQuery("select * from new order by English desc"); while (rs.next()){ id=rs.getString("id"); name=rs.getString("name"); math=rs.getFloat("math"); english=rs.getFloat("English"); politics=rs.getFloat("politics"); algebra=rs.getFloat("algebra"); probability=rs.getFloat("probability"); logic=rs.getFloat("logic"); Object temp1[]={id,name,math,english,politics,algebra,probability,logic}; jTableabc.addRow(temp1); } rs.close(); stmt.close(); con.close(); } catch(Exception e){e.printStackTrace();} }//GEN-LAST:event_jMenuItem6ActionPerformed private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed DefaultTableModel jTableabc=(DefaultTableModel)jTable1.getModel(); jTableabc.setRowCount(0); try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=denghan","sa",""); Statement stmt = con.createStatement(); ResultSet rs =stmt.executeQuery("select * from new order by politics desc"); while (rs.next()){ id=rs.getString("id"); name=rs.getString("name"); math=rs.getFloat("math"); english=rs.getFloat("English"); politics=rs.getFloat("politics"); algebra=rs.getFloat("algebra"); probability=rs.getFloat("probability"); logic=rs.getFloat("logic"); Object temp1[]={id,name,math,english,politics,algebra,probability,logic}; jTableabc.addRow(temp1); } rs.close(); stmt.close(); con.close(); } catch(Exception e){e.printStackTrace();} }//GEN-LAST:event_jMenuItem7ActionPerformed private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed DefaultTableModel jTableabc=(DefaultTableModel)jTable1.getModel(); jTableabc.setRowCount(0); try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=denghan","sa",""); Statement stmt = con.createStatement(); ResultSet rs =stmt.executeQuery("select * from new order by algebra desc"); while (rs.next()){ id=rs.getString("id"); name=rs.getString("name"); math=rs.getFloat("math"); english=rs.getFloat("English"); politics=rs.getFloat("politics"); algebra=rs.getFloat("algebra"); probability=rs.getFloat("probability"); logic=rs.getFloat("logic"); Object temp1[]={id,name,math,english,politics,algebra,probability,logic}; jTableabc.addRow(temp1); } rs.close(); stmt.close(); con.close(); } catch(Exception e){e.printStackTrace();} }//GEN-LAST:event_jMenuItem8ActionPerformed private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed DefaultTableModel jTableabc=(DefaultTableModel)jTable1.getModel(); jTableabc.setRowCount(0); try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=denghan","sa",""); Statement stmt = con.createStatement(); ResultSet rs =stmt.executeQuery("select * from new order by probability desc"); while (rs.next()){ id=rs.getString("id
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -