id
stringlengths
36
36
text
stringlengths
1
1.25M
cf792851-f7bf-4cd2-8181-b34de69700d2
public void actionPerformed(java.awt.event.ActionEvent evt) { button3ActionPerformed(evt); }
3be88044-7fa0-49c7-92a8-2af4d05257cc
public void actionPerformed(java.awt.event.ActionEvent evt) { button4ActionPerformed(evt); }
7d79fa64-d4fb-4779-bcc4-d65c0213ba50
public void actionPerformed(java.awt.event.ActionEvent evt) { button5ActionPerformed(evt); }
45fedfd6-550d-45ba-a423-10f7627ae86a
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button1ActionPerformed gestioncliente.getCliente().setCedula(txtcedula.getText()); gestioncliente.getCliente().setCedula(txtcedula.getText()); gestioncliente.getCliente().setNombre(txtnombre.getText()); gestioncliente.getCliente().setDireccion(txtdireccion.getText()); gestioncliente.getCliente().setCupo(Double.parseDouble(txtcupo.getText())); try{ gestioncliente.Grabar(); JOptionPane.showMessageDialog(this, "El dato se grabo correctamente"); } catch(SQLException ex){ JOptionPane.showMessageDialog(this, ex.getMessage()); } }//GEN-LAST:event_button1ActionPerformed
f05a8128-3b84-4207-94a2-53b7eeb5cb49
private void button2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button2ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_button2ActionPerformed
6deb57f3-a06e-4c52-afa5-0ac682038db3
private void button3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button3ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_button3ActionPerformed
d7f59e5d-2e0d-440c-9d1f-3f6e1b312b5d
private void button4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button4ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_button4ActionPerformed
717e1a69-58d5-46e5-8b38-fd9f34331670
private void button5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button5ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_button5ActionPerformed
47988731-ba25-49a3-9739-a98699767760
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(Cliente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Cliente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Cliente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Cliente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Cliente().setVisible(true); } }); }
781b37a6-96af-4fba-a0ac-383663e37cc2
public void run() { new Cliente().setVisible(true); }
9e9164eb-6af8-431a-9def-7ee6ec891cbb
public GestionCliente() { Conexion.setCadena("jdbc:mysql://localhost/facturacion"); Conexion.setUsuario("root"); Conexion.setClave(""); }
45cb233e-826a-4490-abd4-2b8a308cd29c
public Cliente getCliente() { return cliente; }
40f631b4-8b2e-4da3-9ab8-61bc2ae7c950
public void setCliente (Cliente cliente){ this.cliente=cliente; }
88793cf2-1bd9-4366-be0e-f4ab61164d63
public void Grabar() throws SQLException { try{ Conexion.GetInstancia().Conectar(); Conexion.GetInstancia().Ejecutar("insert into cliente (cedula, nombre, direccion, cupo) values ('"+cliente.getCedula()+"','"+cliente.getNombre()+"','"+cliente.getDireccion()+"', "+cliente.getCupo()+")"); Conexion.GetInstancia().Desconectar(); } catch(SQLException ex){ throw ex; } }
7427ab33-af09-41f7-a2f7-c3f8add6aa04
public void Modificar() throws SQLException { try{ Conexion.GetInstancia().Conectar(); Conexion.GetInstancia().Ejecutar("update cliente (cedula, nombre, direccion, cupo) values ('"+cliente.getCedula()+"','"+cliente.getNombre()+"','"+cliente.getDireccion()+"', "+cliente.getCupo()+")"); Conexion.GetInstancia().Desconectar(); } catch(SQLException ex){ throw ex; } }
2cc1a888-7469-489a-8bec-3e9a29a1a2ea
public void Nuevo() throws SQLException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
75bff0cd-a597-4ed5-bc2f-2b2e8a450a7e
public void Eliminar() throws SQLException { try{ Conexion.GetInstancia().Conectar(); Conexion.GetInstancia().Ejecutar("delete from cliente where cedula='"+cliente.getCedula()+""); Conexion.GetInstancia().Desconectar(); } catch(SQLException ex){ throw ex; } }
f514379a-067c-4450-b099-3afea694b50b
public void Consultar() throws SQLException { try{ Conexion.GetInstancia().Conectar(); Conexion.GetInstancia().Ejecutar("select * from cliente"); Conexion.GetInstancia().Desconectar(); } catch(SQLException ex){ throw ex; } }
2aa82331-e157-4da3-a81b-ac4c070dce8d
public void Grabar () throws SQLException;
00a0686b-7c5b-4951-8e09-192804dcd842
public void Modificar() throws SQLException;
aeaff3e8-03a4-4eda-8b75-e045ee9139db
public void Nuevo() throws SQLException;
6a000951-c1c4-447d-b405-376ec157410e
public void Eliminar() throws SQLException;
02d27839-6189-419d-aadd-f1cf2c273a55
public void Consultar() throws SQLException;
2a757346-c55a-40fa-8d7c-9742b36ca25b
public String getCedula() { return Cedula; }
eb3a9567-7509-4dd1-a2e6-42234dcbd5c5
public void setCedula(String Cedula) { this.Cedula = Cedula; }
93a77929-0324-4c0a-9eef-e81409b6b563
public String getNombre() { return Nombre; }
6e251c7f-a823-4ca6-aa42-c79183b1dd87
public void setNombre(String Nombre) { this.Nombre = Nombre; }
4648d466-5b88-4e2f-8b22-7d8027248911
public String getDireccion() { return Direccion; }
a40fe962-d884-4cfe-8f11-4472d8b5635b
public void setDireccion(String Direccion) { this.Direccion = Direccion; }
5683cc35-2eba-43f8-88b7-730c0611e615
public double getCupo() { return Cupo; }
d728e6f8-639f-4c6c-a21b-47c385248326
public void setCupo(double Cupo) { this.Cupo = Cupo; }
06a279a4-5cc7-442f-bd38-a9349efd81cc
public Cliente(String Cedula, String Nombre, String Direccion, double Cupo) { this.Cedula = Cedula; this.Nombre = Nombre; this.Direccion = Direccion; this.Cupo = Cupo; }
4868c5ee-c9a7-4015-a371-2f02b96f964f
public static void main(String[] args) { System.out.println("A.main(String[] args)"); A a = new A(); a.mth1(Integer.parseInt(args[0])); }
313a8bf9-8dca-4851-a1ee-5139eeabd0f6
public void mth1(int count) { System.out.println("A.mth1(int count)"); B b = new B(); for(int i = 0; i < count; i++) { try { b.mth1(i); b.mth2(); } catch (Exception e) { System.err.println("error in A.mth1(int count)"); } } }
bd20e829-26e7-423f-97c4-2f3a8071bb0d
public void mth1(int i) { System.out.println("B.mth1(int i)"); C c = new C(i); int result = c.mth1(); System.out.println("result = " + result); }
44cd6f1f-198d-4745-b8f7-5b57d265051f
public void mth2() { System.out.println("B.mth2()"); }
ee35a5d9-2e28-45d3-aa75-0710d1017158
public C(int i) { System.out.println("C.C(int i)"); this.i = i; }
bec6e0ee-85a9-4703-9ea6-5c00436b5ecc
public int mth1() { System.out.println("C.mth1()"); return 100/i; }
d7954132-0639-43cb-b9b4-91cb1d30ead7
public static void main(String[] args) throws IOException { InstruNumberCall instru = new InstruNumberCall(args[0], args[1], new LogProcessorMethodNumber()); //copy the project (args[0]) in the output directory (args[1]) instru.initOutputDirectory(); //instrumentalize the java code of output directory with LogProcessor instru.instru(); }
cf885b5e-ed57-448d-bfdc-9f7fc2234488
public InstruNumberCall(String projectDirectory, String outputDirectory, Processor processor) { this.projectDirectory = projectDirectory; this.outputDirectory = outputDirectory; this.processor = processor; }
cdeeedff-d688-41cd-a0e3-2d519ab541ad
public void instru() throws IOException { String src = projectDirectory + System.getProperty("file.separator") + srcDirectory; String out = outputDirectory + System.getProperty("file.separator") + srcDirectory; //initialize spoon Factory factory = initSpoon(src); //apply the processor applyProcessor(factory, processor); //write the intrumentalize java code into the output directory Environment env = factory.getEnvironment(); env.useSourceCodeFragments(true); applyProcessor(factory, new SimpleJavaOutputProcessor(new File(out), new FragmentDrivenJavaPrettyPrinter(env))); //copy LogWriter and ShutdownHookLog into the output directory copyLoggerFile(outputDirectory, srcDirectory); }
9f0b3ebe-a3bb-4b07-bca9-fa036c6ed2d6
protected void initOutputDirectory() throws IOException { File dir = new File(outputDirectory); dir.mkdirs(); FileUtils.copyDirectory(new File(projectDirectory), dir); }
0fd2db13-9844-4a10-84d6-43fa741a2b65
protected Factory initSpoon(String srcDirectory) { StandardEnvironment env = new StandardEnvironment(); env.setVerbose(true); env.setDebug(true); DefaultCoreFactory f = new DefaultCoreFactory(); Factory factory = new FactoryImpl(f, env); SpoonCompiler c = new JDTBasedSpoonCompiler(factory); for (String dir : srcDirectory.split(System.getProperty("path.separator"))) try { c.addInputSource(new File(dir)); } catch (IOException e) { e.printStackTrace(); } try { c.build(); } catch (Exception e) { e.printStackTrace(); } return factory; }
4f461e0a-ed05-47b1-8284-818a4bfc870d
protected void applyProcessor(Factory factory, Processor processor) { ProcessingManager pm = new QueueProcessingManager(factory); pm.addProcessor(processor); pm.process(); }
9053b5d8-0f17-40d7-907c-3fcd4706ece8
protected void copyLoggerFile(String tmpDir, String src) throws IOException { File dir = new File(tmpDir+"/"+src+"/vv/spoonNumberCall/logger"); FileUtils.forceMkdir(dir); String packagePath = System.getProperty("user.dir")+"/src/main/java/vv/spoonNumberCall/logger/"; FileUtils.copyFileToDirectory(new File(packagePath + LogWriterNum.class.getSimpleName() + ".java"), dir); FileUtils.copyFileToDirectory(new File(packagePath + ShutdownHookLog1.class.getSimpleName() + ".java"), dir); }
ef3b82aa-1a08-474b-8dce-fc6dcd9f43f8
public SimpleJavaOutputProcessor(File outputDirectory, PrettyPrinter printer) { super(outputDirectory, printer); }
9787f8ec-6898-4fc1-b395-91138dde7967
public void process(CtSimpleType<?> type) { if (type.isTopLevel()) createJavaFile(type); }
bac1fd98-fc16-407d-a83a-3e865d0ad380
@Override public void process(CtMethod element) { SourcePosition sp = element.getPosition(); CompilationUnit compileUnit = sp.getCompilationUnit(); //add /** before the invocation //SourceCodeFragment before = new SourceCodeFragment(compileUnit.beginOfLineIndex(sp.getSourceStart()), "/**", 0); //compileUnit.addSourceCodeFragment(before); //add **/ vv.spoon.logger.LogWriter.out( argument, newline, error); after the invocation //Object argument = element.getArguments().get(0); // String snippet = "**/\n\t\tvv.spoon.logger.LogWriter.out(" + argument // + "," + isError(element.getTarget()) + ");\n"; String classname=element.getDeclaringType().getQualifiedName(); String methodSign=classname+"."+element.getSignature(); String snippet = "\n\t\tvv.spoonNumberCall.logger.LogWriterNum.addEntry(\""+methodSign+"\");\n"; SourceCodeFragment after = new SourceCodeFragment(compileUnit.nextLineIndex(sp.getSourceEnd()), snippet, 0); compileUnit.addSourceCodeFragment(after); CtCodeSnippetStatement ctcode=getFactory().Core().createCodeSnippetStatement(); ctcode.setValue(snippet); element.getBody().addStatement(ctcode); }
ab403968-bb1d-41f3-bb17-aedb31a5748a
public void run() { LogWriterNum.writeLog(); }
7ba1ba3d-1c08-4615-8455-f0ca73e35650
public static void writeLog() { out(); fileWriter.close(); }
8eaf8a13-4842-4489-a86b-47cc5dbf80fa
public static void out() { try { PrintWriter writer = getWriter(); Iterator<Map.Entry<String, Integer>> entries=(callmethod.entrySet()).iterator(); while(entries.hasNext()){ Map.Entry entry=entries.next(); String st=entry.getKey()+"\t"+entry.getValue(); writer.write(st + "\n"); } } catch (FileNotFoundException e) { e.printStackTrace(); } finally { fileWriter.close(); } }
890a9300-3260-4ff6-9bf7-b7ef73a427d0
protected static PrintWriter getWriter() throws FileNotFoundException { if(fileWriter == null) { //ShutdownHookLog1 shutdownHook = new ShutdownHookLog1(); //Runtime.getRuntime().addShutdownHook(shutdownHook); fileWriter = new PrintWriter("logCompter"); } return fileWriter; }
73d7ade2-3ac0-4db8-b683-3cfe411b6487
public static void addEntry(String key){ addHook(); if (callmethod.containsKey(key)){ int value=callmethod.get(key); value++; callmethod.put(key,value); } else { callmethod.put(key,1); } }
c7d1e79c-575e-4315-8770-adcc14b68ba1
public static void addHook(){ if(shutdownHook==null){ shutdownHook=new ShutdownHookLog1(); Runtime.getRuntime().addShutdownHook(shutdownHook); } }
859ef785-a6f8-4f81-919a-6ff13cdfc9f6
public Instru(String projectDirectory, String outputDirectory, Processor processor) { this.projectDirectory = projectDirectory; this.outputDirectory = outputDirectory; this.processor = processor; }
27587fad-073f-4b2b-8ae8-611034839500
public void instru() throws IOException { String src = projectDirectory + System.getProperty("file.separator") + srcDirectory; String out = outputDirectory + System.getProperty("file.separator") + srcDirectory; //initialize spoon Factory factory = initSpoon(src); //apply the processor applyProcessor(factory, processor); //write the intrumentalize java code into the output directory Environment env = factory.getEnvironment(); env.useSourceCodeFragments(true); applyProcessor(factory, new SimpleJavaOutputProcessor(new File(out), new FragmentDrivenJavaPrettyPrinter(env))); //copy LogWriter and ShutdownHookLog into the output directory copyLoggerFile(outputDirectory, srcDirectory); }
0ae1e862-65fd-401f-8d4f-b6fc7d1c37ab
protected void initOutputDirectory() throws IOException { File dir = new File(outputDirectory); dir.mkdirs(); FileUtils.copyDirectory(new File(projectDirectory), dir); }
fc80de01-aee0-4a6f-b385-87917209f68b
protected Factory initSpoon(String srcDirectory) { StandardEnvironment env = new StandardEnvironment(); env.setVerbose(true); env.setDebug(true); DefaultCoreFactory f = new DefaultCoreFactory(); Factory factory = new FactoryImpl(f, env); SpoonCompiler c = new JDTBasedSpoonCompiler(factory); for (String dir : srcDirectory.split(System.getProperty("path.separator"))) try { c.addInputSource(new File(dir)); } catch (IOException e) { e.printStackTrace(); } try { c.build(); } catch (Exception e) { e.printStackTrace(); } return factory; }
cf9e28af-b9d6-475e-a5ef-6d02edd7956a
protected void applyProcessor(Factory factory, Processor processor) { ProcessingManager pm = new QueueProcessingManager(factory); pm.addProcessor(processor); pm.process(); }
57b2abf6-cf59-4e95-81ed-5126bc86964d
protected void copyLoggerFile(String tmpDir, String src) throws IOException { File dir = new File(tmpDir+"/"+src+"/vv/spoon/logger"); FileUtils.forceMkdir(dir); String packagePath = System.getProperty("user.dir")+"/src/main/java/vv/spoon/logger/"; FileUtils.copyFileToDirectory(new File(packagePath + LogWriter.class.getSimpleName() + ".java"), dir); FileUtils.copyFileToDirectory(new File(packagePath + ShutdownHookLog.class.getSimpleName() + ".java"), dir); }
7b76c969-88b2-4984-8bc8-ab545f65d0d3
public static void main(String[] args) throws IOException { Instru instru = new Instru(args[0], args[1], new LogProcessor()); //copy the project (args[0]) in the output directory (args[1]) instru.initOutputDirectory(); //instrumentalize the java code of output directory with LogProcessor instru.instru(); }
3fc4d3e5-a7d9-433f-9d31-cedd43066a54
public SimpleJavaOutputProcessor(File outputDirectory, PrettyPrinter printer) { super(outputDirectory, printer); }
85dc7884-2c36-4559-bb39-5faa27dcfbc4
public void process(CtSimpleType<?> type) { if (type.isTopLevel()) createJavaFile(type); }
63b1fe21-d8cb-436c-8310-25e6d1603095
@Override public boolean isToBeProcessed(CtInvocation candidate) { try { Class type = candidate.getTarget().getType().getActualClass(); CtExecutableReference executable = candidate.getExecutable(); if(type.equals(java.io.PrintStream.class) && isPrint(executable)) { return true; } return false; } catch (Exception e) { return false; } }
1cd7e36b-bf30-4971-932a-b2e082d72b28
@Override public void process(CtInvocation element) { SourcePosition sp = element.getPosition(); CompilationUnit compileUnit = sp.getCompilationUnit(); //add /** before the invocation SourceCodeFragment before = new SourceCodeFragment(compileUnit.beginOfLineIndex(sp.getSourceStart()), "/**", 0); compileUnit.addSourceCodeFragment(before); //add **/ vv.spoon.logger.LogWriter.out( argument, newline, error); after the invocation Object argument = element.getArguments().get(0); String snippet = "**/\n\t\tvv.spoon.logger.LogWriter.out(" + argument + "," + isError(element.getTarget()) + ");\n"; SourceCodeFragment after = new SourceCodeFragment(compileUnit.nextLineIndex(sp.getSourceEnd()), snippet, 0); compileUnit.addSourceCodeFragment(after); }
9c92212b-d8ba-404c-84b1-b859d2fc901e
protected boolean isError(CtExpression target) { return target.toString().endsWith("err"); }
bc642c01-b000-49c2-957f-3e02513d368f
protected boolean isPrint(CtExecutableReference executable) { String toString = executable.toString(); return toString.startsWith("java.io.PrintStream.println(") || toString.startsWith("java.io.PrintStream.print("); }
79b9f9e6-80d9-423b-91fd-a046fb17fbb9
public void run() { LogWriter.writeLog(); }
5bdc24e4-c9fb-46a0-9a16-9e71b1058b69
public static void writeLog() { fileWriter.close(); }
71c56f92-ea0f-452e-84bc-0feaee16798e
public static void out(String string, boolean error) { try { PrintWriter writer = getWriter(); if(error) { writer.write("ERROR: "); } else { writer.write("INFO: "); } writer.write(string + "\n"); } catch (FileNotFoundException e) { e.printStackTrace(); } }
50e43aca-60d4-421d-aa52-8697252c27cc
protected static PrintWriter getWriter() throws FileNotFoundException { if(fileWriter == null) { ShutdownHookLog shutdownHook = new ShutdownHookLog(); Runtime.getRuntime().addShutdownHook(shutdownHook); fileWriter = new PrintWriter("log"); } return fileWriter; }
5394846a-99cf-4eca-8fe8-29b4b004afb4
public void acceptStudent(String id) { updateStatus(id, "Y"); }
e995e09c-6b22-40f4-acbf-61d256257bc9
public void denyStudent(String id) { updateStatus(id, "D"); }
4cec9558-8013-4c3a-8087-3568d7b7d90b
public void ptStudent(String id) { updateStatus(id, "P"); }
604a71da-420f-474a-97fc-eb30896f5af1
void updateStatus(String id,String status) { try { conn = GetConnection.getConnection(); sql = "update cms_register_student set isAccept = '" + status + "' where id = ?"; pstat = conn.prepareStatement(sql); pstat.setString(1, id); pstat.executeUpdate(); } catch(Exception e) { e.printStackTrace(); } finally { if(pstat!=null) { try { pstat.close(); } catch (SQLException e) { e.printStackTrace(); } } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
16a6054b-f1f7-4826-991b-074b2d4c9f63
public void deleteStudent(String id) { try { conn = GetConnection.getConnection(); sql = "delete from cms_register_student where id = ?"; pstat = conn.prepareStatement(sql); pstat.setString(1, id); pstat.executeUpdate(); } catch(Exception e) { e.printStackTrace(); } finally { if(pstat!=null) { try { pstat.close(); } catch (SQLException e) { e.printStackTrace(); } } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
d1df995c-6df8-4a71-8efd-815f31e8be61
public List<Student> getAllStudents() { return getStudents(" order by addtime"); }
2730d9ec-c077-4813-b514-00f894e50b98
public List<Student> getAcceptedStudents() { return getStudents("where isAccept = 'Y' or isAccept = 'P' order by isAccept desc"); }
31715e02-1164-47f8-a34f-9e0adf26a16a
public String getStatusById(String tidcard, String ttel) { List<Student> list = getStudents(" where idcard = '" + tidcard + "' and tel = '" + ttel + "'"); if(list==null || list.size()<1) { return null; } else { Student student = list.get(0); return student.getIsAcceptInner(); } }
9d50a422-1b89-4767-9e87-17dc69438616
List<Student> getStudents(String whereSql) { List<Student> acceptedStudents = new ArrayList<Student>(); ResultSet rs = null; try { conn = GetConnection.getConnection(); sql = "select id,name,sex,type,school,academy,major,grade,research,email,tel,teacher,idcard,isAccept,addtime from cms_register_student " + whereSql; pstat = conn.prepareStatement(sql); rs = (ResultSet) pstat.executeQuery(); while(rs.next()) { Student stu = new Student(); stu.setId(rs.getString("id")); stu.setName(rs.getString("name")); stu.setSex(rs.getString("sex")); stu.setType(rs.getString("type")); stu.setSchool(rs.getString("school")); stu.setAcademy(rs.getString("academy")); stu.setMajor(rs.getString("major")); stu.setGrade(rs.getString("grade")); stu.setResearch(rs.getString("research")); stu.setEmail(rs.getString("email")); stu.setTel(rs.getString("tel")); stu.setTeacher(rs.getString("teacher")); stu.setIdcard(rs.getString("idcard")); String status = rs.getString("isAccept"); stu.setIsAcceptInner(status); if("Y".equalsIgnoreCase(status)) { stu.setIsAccept("<font color='green'>正式学员</font>"); } else if("D".equalsIgnoreCase(status)) { stu.setIsAccept("未录取"); } else if("P".equalsIgnoreCase(status)) { stu.setIsAccept("旁听学员"); } else { stu.setIsAccept("<font color='red'>未审核</font>"); } stu.setAddtime(rs.getTimestamp("addtime")); acceptedStudents.add(stu); } } catch(Exception e) { e.printStackTrace(); } finally { if(rs!=null) { try { rs.close(); } catch (SQLException e) { e.printStackTrace(); } } if(pstat!=null) { try { pstat.close(); } catch (SQLException e) { e.printStackTrace(); } } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } return acceptedStudents; }
589ff9bd-0f73-4718-8669-52ea2237f94a
public boolean addStudent(Student user) throws Exception { sql = "insert into cms_register_student values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; try { conn = GetConnection.getConnection(); pstat = conn.prepareStatement(sql); String id; if(user.getIdcard()!=null) { id = user.getIdcard(); } else { id = UUID.randomUUID().toString(); } pstat.setString(1, id); pstat.setString(2, user.getName()); pstat.setString(3, user.getSex()); pstat.setString(4, user.getType()); pstat.setString(5, user.getSchool()); pstat.setString(6, user.getAcademy()); pstat.setString(7, user.getMajor()); pstat.setString(8, user.getGrade()); pstat.setString(9, user.getResearch()); pstat.setString(10, user.getEmail()); pstat.setString(11, user.getTel()); pstat.setString(12, user.getTeacher()); pstat.setString(13, user.getIdcard()); pstat.setString(14, "N"); pstat.setNull(15, java.sql.Types.VARCHAR); pstat.setNull(16, java.sql.Types.DATE); pstat.setTimestamp(17, new Timestamp(System.currentTimeMillis())); pstat.executeUpdate(); return true; } catch (SQLException e) { e.printStackTrace(); throw e; } finally { if(pstat!=null) { try { pstat.close(); } catch (SQLException e) { e.printStackTrace(); } } if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
afb86028-10e2-4b8b-94e9-7e6b44f17562
public static void main(String[] args) { // System.out.println(new Date().getTime() + "," + System.currentTimeMillis()); // new Dao().deleteStudent("99"); Testao dao = new Testao(); List<Student> allStudents = dao.getAllStudents(); System.out.println(allStudents.size()); System.out.println(dao.getAcceptedStudents().size()); }
169d9409-ff34-4e6a-97eb-4692bb404537
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { List<Student> list = new ArrayList<Student>(); System.out.println("in UUServlet.service2..." + list.size()); String method = req.getParameter("method"); String id = req.getParameter("id"); Testao testao = new Testao(); if("update".equalsIgnoreCase(method)) { testao.acceptStudent(id); } else if("delete".equalsIgnoreCase(method)) { testao.deleteStudent(id); } else if("updateD".equalsIgnoreCase(method)) { testao.denyStudent(id); } else if("updatePT".equalsIgnoreCase(method)) { testao.ptStudent(id); } list = testao.getAllStudents(); req.setAttribute("list", list); if("excel".equalsIgnoreCase(method)) { req.getRequestDispatcher("zexcel.jsp").forward(req,resp); } else { req.getRequestDispatcher("zsmanager.jsp").forward(req,resp); } }
de8b51fd-ac0a-4d9e-811d-e8156b1fd76a
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("in ActionServlet.service..."); request.setCharacterEncoding("utf-8"); Testao dao = new Testao(); String method = request.getParameter("method"); if(method!=null && method.length()>0 && "search".equalsIgnoreCase(method)) { String tidcard = request.getParameter("tidcard"); String ttel = request.getParameter("ttel"); String status = dao.getStatusById(tidcard,ttel); String msg = ""; if(status==null) { msg = "学员未报名或查询信息不正确,请核对!"; } else{ if("Y".equalsIgnoreCase(status)) { msg = "已录取为正式学员!"; } else if("N".equalsIgnoreCase(status)) { msg = "报名已成功,正在录取审核中!"; } else if("P".equalsIgnoreCase(status)) { msg = "已录取为旁听学员!"; } else if("D".equalsIgnoreCase(status)) { msg = "未被录取,谢谢关注!"; } else { System.out.println("!!!!not contain = " + status); } } System.out.println("!!!!msg = " + msg); request.setAttribute("info", msg); request.getRequestDispatcher("zinfo.jsp").forward(request, response); } else { Student st = new Student(); String tname = request.getParameter("tname"); st.setName(tname); String tsex = request.getParameter("tsex"); st.setSex(tsex); String ttype = request.getParameter("ttype"); st.setType(ttype); String tschool = request.getParameter("tschool"); st.setSchool(tschool); String tacademy = request.getParameter("tacademy"); st.setAcademy(tacademy); String tmajor = request.getParameter("tmajor"); st.setMajor(tmajor); String tgrade = request.getParameter("tgrade"); st.setGrade(tgrade); String tresearch = request.getParameter("tresearch"); st.setResearch(tresearch); String temail = request.getParameter("temail"); st.setEmail(temail); String ttel = request.getParameter("ttel"); st.setTel(ttel); String tteacher = request.getParameter("tteacher"); st.setTeacher(tteacher); String tidcard = request.getParameter("tidcard"); st.setIdcard(tidcard); boolean isOK; try { isOK = dao.addStudent(st); if (isOK) { request.setAttribute("info", "恭喜你 " + tname + ", 报名成功!"); request.getRequestDispatcher("zinfo.jsp").forward(request, response); } else { request.setAttribute("info", "报名失败!"); request.getRequestDispatcher("zinfo.jsp").forward(request, response); } } catch (Exception e) { String errMsg = e.getMessage(); if(e.getMessage().contains("Duplicate entry")) { errMsg = "你已报名,可通过“报名状态查询”查询状态!"; } else { errMsg = "报名失败," + e.getMessage(); } System.out.println("errMsg = " + errMsg); request.setAttribute("info", errMsg); request.getRequestDispatcher("zinfo.jsp").forward(request, response); } } }
0d14f713-d31e-4d84-9ee9-1cb87a5b7333
@Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("in AAListServlet.service222..."); Testao dao = new Testao(); List<Student> acceptedStudents = dao.getAcceptedStudents(); req.setAttribute("list", acceptedStudents); req.getRequestDispatcher("zslist.jsp").forward(req,resp); }
3bf8e861-6d00-41ae-b6c3-980c25dc04fb
public static Connection getConnection() { String driver = "org.gjt.mm.mysql.Driver"; String url = "jdbc:mysql://localhost:3306/cms?useUnicode=true&characterEncoding=utf-8"; Connection con = null; try { Class.forName(driver); try { System.out.println(url); con = DriverManager.getConnection(url, "root", "admin"); } catch (SQLException e) { e.printStackTrace(); } } catch (ClassNotFoundException e) { e.printStackTrace(); } return con; }
80d8ec27-cc8a-43cd-9401-6d4358c638b3
public String getId() { return id; }
932a285e-29bb-481f-885f-ee5cc21be97a
public void setId(String id) { this.id = id; }
4eb08e4d-5e5e-4fb1-9dd9-34379d29c7d3
public String getName() { return name; }
e12ac218-6d79-46f3-9870-154808c9d31d
public void setName(String name) { this.name = name; }
c0c6535e-d243-4fa2-bec8-3700831f6d94
public String getSex() { return sex; }
8baa39db-897f-43f7-9899-1075c3b96e1a
public void setSex(String sex) { this.sex = sex; }
84ae75fc-21e4-4eb6-b60b-6acdc58f7967
public String getSchool() { return school; }
a1518de6-1e46-49d5-8ba2-907d0500c153
public void setSchool(String school) { this.school = school; }
0c541509-6b51-4909-8186-8f45757c2493
public String getAcademy() { return academy; }
8a1ff4a0-01aa-4ce5-9bbd-eba8d3e878f4
public void setAcademy(String academy) { this.academy = academy; }
2a39fe9d-bc54-44c5-a2f3-6b1a67c4f64b
public String getMajor() { return major; }
43038a33-c233-454a-bedf-66e8489e0d7d
public void setMajor(String major) { this.major = major; }
70129be2-9ae3-4aa7-a8b7-030bc89ac7a7
public String getGrade() { return grade; }
37f048bf-52b7-462b-9b51-854ed141f341
public void setGrade(String grade) { this.grade = grade; }