@Override public Set<EmpVO> getEmpsByDeptno(Integer deptno) { Set<EmpVO> set = new LinkedHashSet<EmpVO>(); EmpVO empVO = null; Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; try { Class.forName(driver); con = DriverManager.getConnection(url, userid, passwd); pstmt = con.prepareStatement(GET_Emps_ByDeptno_STMT); pstmt.setInt(1, deptno); rs = pstmt.executeQuery(); while (rs.next()) { empVO = new EmpVO(); empVO.setEmpno(rs.getInt("empno")); empVO.setEname(rs.getString("ename")); empVO.setJob(rs.getString("job")); empVO.setHiredate(rs.getDate("hiredate")); empVO.setSal(rs.getDouble("sal")); empVO.setComm(rs.getDouble("comm")); empVO.setDeptno(rs.getInt("deptno")); set.add(empVO); // Store the row in the vector } // Handle any driver errors } catch (ClassNotFoundException e) { throw new RuntimeException("Couldn't load database driver. " + e.getMessage()); // Handle any SQL errors } catch (SQLException se) { throw new RuntimeException("A database error occured. " + se.getMessage()); } finally { if (rs != null) { try { rs.close(); } catch (SQLException se) { se.printStackTrace(System.err); } } if (pstmt != null) { try { pstmt.close(); } catch (SQLException se) { se.printStackTrace(System.err); } } if (con != null) { try { con.close(); } catch (Exception e) { e.printStackTrace(System.err); } } } return set; }
private Map<String, SpringResource> generateResourceMap(Set<Class<?>> validClasses) throws GenerateException { Map<String, SpringResource> resourceMap = new HashMap<String, SpringResource>(); for (Class<?> c : validClasses) { RequestMapping requestMapping = c.getAnnotation(RequestMapping.class); String description = ""; // This try/catch block is to stop a bamboo build from failing due to NoClassDefFoundError // This occurs when a class or method loaded by reflections contains a type that has no // dependency try { resourceMap = analyzeController(c, resourceMap, description); List<Method> mList = new ArrayList<Method>(Arrays.asList(c.getMethods())); if (c.getSuperclass() != null) { mList.addAll(Arrays.asList(c.getSuperclass().getMethods())); } } catch (NoClassDefFoundError e) { LOG.error(e.getMessage()); LOG.info(c.getName()); // exception occurs when a method type or annotation is not recognized by the plugin } catch (ClassNotFoundException e) { LOG.error(e.getMessage()); LOG.info(c.getName()); } } return resourceMap; }
protected void checkReturn(Stmt.Return ret) { JavaMethod method = (JavaMethod) getEnclosingScope(JavaMethod.class); if (method instanceof JavaConstructor) { return; // could do better than this. } Type retType = method.returnType().attribute(Type.class); if (ret.expr() != null) { checkExpression(ret.expr()); Type ret_t = ret.expr().attribute(Type.class); try { if (ret_t.equals(new Type.Void())) { syntax_error("cannot return a value from method whose result type is void", ret); } else if (!types.subtype(retType, ret_t, loader)) { syntax_error("required return type " + retType + ", found type " + ret_t, ret); } } catch (ClassNotFoundException ex) { syntax_error(ex.getMessage(), ret); } } else if (!(retType instanceof Type.Void)) { syntax_error("missing return value", ret); } }
public String buscarEmpleado(String codigo) { try { cn = Conexion.realizarConexion(); st = cn.createStatement(); String sql = "select chr_emplcodigo from empleado " + " where chr_emplcodigo = '" + codigo + "'"; rs = st.executeQuery(sql); while (rs.next()) { return rs.getString("chr_emplcodigo"); } } catch (ClassNotFoundException ex) { showMessageDialog(null, ex.getMessage(), "Excepción", 0); } catch (SQLException ex) { showMessageDialog(null, ex.getMessage(), "Excepción", 0); } finally { try { rs.close(); st.close(); cn.close(); } catch (Exception ex) { showMessageDialog(null, ex.getMessage(), "Excepción", 0); } } return null; }
public ArrayList<Empleado> listarEmpleado() { ArrayList<Empleado> emple = new ArrayList<Empleado>(); try { cn = Conexion.realizarConexion(); st = cn.createStatement(); String sql = "select * from empleado"; rs = st.executeQuery(sql); while (rs.next()) { emple.add( new Empleado( rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(7), rs.getString(8))); } } catch (ClassNotFoundException ex) { showMessageDialog(null, ex.getMessage(), "Excepción", 0); } catch (SQLException ex) { showMessageDialog(null, ex.getMessage(), "Excepción", 0); } finally { try { rs.close(); st.close(); cn.close(); } catch (Exception ex) { showMessageDialog(null, ex.getMessage(), "Excepción", 0); } } return emple; }
public String insertarEmpleado(Empleado empleado) { String mensaje = null; try { cn = Conexion.realizarConexion(); String sql = "insert into empleado values(?,?,?,?,?,?,?,?)"; ps = cn.prepareStatement(sql); ps.setString(1, empleado.getCodigo()); ps.setString(2, empleado.getPaterno()); ps.setString(3, empleado.getMaterno()); ps.setString(4, empleado.getNombre()); ps.setString(5, empleado.getCiudad()); ps.setString(6, empleado.getDireccion()); ps.setString(7, empleado.getUsuario()); ps.setString(8, empleado.getClave()); ps.executeUpdate(); } catch (ClassNotFoundException ex) { mensaje = ex.getMessage(); } catch (SQLException ex) { mensaje = ex.getMessage(); } finally { try { ps.close(); cn.close(); } catch (Exception ex) { mensaje = ex.getMessage(); } } return mensaje; }
protected void checkVarDef(Stmt.VarDef def) { // Observe that we cannot use the declared type here, rather we have to // use the resolved type! Type t = def.type().attribute(Type.class); for (Triple<String, Integer, Expr> d : def.definitions()) { if (d.third() != null) { checkExpression(d.third()); Type nt = t; for (int i = 0; i != d.second(); ++i) { nt = new Type.Array(nt); } Type i_t = d.third().attribute(Type.class); try { if (!types.subtype(nt, i_t, loader)) { ErrorHandler.handleTypeMismatch( new TypeMismatchException(d.third(), nt, loader, types), d.third().attribute(SourceLocation.class)); } } catch (ClassNotFoundException ex) { syntax_error(ex.getMessage(), def); } } } }
@Override public void delete(Integer deptno) { int updateCount_EMPs = 0; Connection con = null; PreparedStatement pstmt = null; try { Class.forName(driver); con = DriverManager.getConnection(url, userid, passwd); // 1●設定於 pstm.executeUpdate()之前 con.setAutoCommit(false); // 先刪除員工 pstmt = con.prepareStatement(DELETE_EMPs); pstmt.setInt(1, deptno); updateCount_EMPs = pstmt.executeUpdate(); // 再刪除部門 pstmt = con.prepareStatement(DELETE_DEPT); pstmt.setInt(1, deptno); pstmt.executeUpdate(); // 2●設定於 pstm.executeUpdate()之後 con.commit(); con.setAutoCommit(true); System.out.println("刪除部門編號" + deptno + "時,共有員工" + updateCount_EMPs + "人同時被刪除"); // Handle any driver errors } catch (ClassNotFoundException e) { throw new RuntimeException("Couldn't load database driver. " + e.getMessage()); // Handle any SQL errors } catch (SQLException se) { if (con != null) { try { // 3●設定於當有exception發生時之catch區塊內 con.rollback(); } catch (SQLException excep) { throw new RuntimeException("rollback error occured. " + excep.getMessage()); } } throw new RuntimeException("A database error occured. " + se.getMessage()); } finally { if (pstmt != null) { try { pstmt.close(); } catch (SQLException se) { se.printStackTrace(System.err); } } if (con != null) { try { con.close(); } catch (Exception e) { e.printStackTrace(System.err); } } } }
public void testExceptionHandling() { final ComponentAdapter componentAdapter = new ThreadLocalizing.ThreadLocalized( new ConstructorInjection.ConstructorInjector( TargetInvocationExceptionTester.class, ThrowingComponent.class, null)); final TargetInvocationExceptionTester tester = (TargetInvocationExceptionTester) componentAdapter.getComponentInstance(null, ComponentAdapter.NOTHING.class); try { tester.throwsCheckedException(); fail("ClassNotFoundException expected"); } catch (final ClassNotFoundException e) { assertEquals("junit", e.getMessage()); } try { tester.throwsRuntimeException(); fail("RuntimeException expected"); } catch (final RuntimeException e) { assertEquals("junit", e.getMessage()); } try { tester.throwsError(); fail("Error expected"); } catch (final Error e) { assertEquals("junit", e.getMessage()); } }
@Override public DeptVO findByPrimaryKey(Integer deptno) { DeptVO deptVO = null; Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; try { Class.forName(driver); con = DriverManager.getConnection(url, userid, passwd); pstmt = con.prepareStatement(GET_ONE_STMT); pstmt.setInt(1, deptno); rs = pstmt.executeQuery(); while (rs.next()) { // deptVO 也稱為 Domain objects deptVO = new DeptVO(); deptVO.setDeptno(rs.getInt("deptno")); deptVO.setDname(rs.getString("dname")); deptVO.setLoc(rs.getString("loc")); } // Handle any driver errors } catch (ClassNotFoundException e) { throw new RuntimeException("Couldn't load database driver. " + e.getMessage()); // Handle any SQL errors } catch (SQLException se) { throw new RuntimeException("A database error occured. " + se.getMessage()); // Clean up JDBC resources } finally { if (rs != null) { try { rs.close(); } catch (SQLException se) { se.printStackTrace(System.err); } } if (pstmt != null) { try { pstmt.close(); } catch (SQLException se) { se.printStackTrace(System.err); } } if (con != null) { try { con.close(); } catch (Exception e) { e.printStackTrace(System.err); } } } return deptVO; }
public OriundoDAO() { try { Class.forName(new conexao().config.getString("driver")); } catch (ClassNotFoundException ex) { JOptionPane.showMessageDialog( null, "Driver Erro: " + ex.getMessage(), "Construtor da Classe", 0); ex.printStackTrace(); } }
@Override public List<DeptVO> getAll() { List<DeptVO> list = new ArrayList<DeptVO>(); DeptVO deptVO = null; Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; try { Class.forName(driver); con = DriverManager.getConnection(url, userid, passwd); pstmt = con.prepareStatement(GET_ALL_STMT); rs = pstmt.executeQuery(); while (rs.next()) { deptVO = new DeptVO(); deptVO.setDeptno(rs.getInt("deptno")); deptVO.setDname(rs.getString("dname")); deptVO.setLoc(rs.getString("loc")); list.add(deptVO); // Store the row in the list } // Handle any driver errors } catch (ClassNotFoundException e) { throw new RuntimeException("Couldn't load database driver. " + e.getMessage()); // Handle any SQL errors } catch (SQLException se) { throw new RuntimeException("A database error occured. " + se.getMessage()); } finally { if (rs != null) { try { rs.close(); } catch (SQLException se) { se.printStackTrace(System.err); } } if (pstmt != null) { try { pstmt.close(); } catch (SQLException se) { se.printStackTrace(System.err); } } if (con != null) { try { con.close(); } catch (Exception e) { e.printStackTrace(System.err); } } } return list; }
protected void checkConvert(Expr.Convert e) { Type rhs_t = e.expr().attribute(Type.class); Type c_t = (Type) e.type().attribute(Type.class); try { if (!types.subtype(c_t, rhs_t, loader)) { ErrorHandler.handleTypeMismatch( new TypeMismatchException(e.expr(), c_t, loader, types), e.expr().attribute(SourceLocation.class)); } } catch (ClassNotFoundException ex) { syntax_error(ex.getMessage(), e); } }
/** * Constructs a <code>DataFlavor</code> that represents a <code>MimeType</code>. * * <p>The returned <code>DataFlavor</code> will have the following characteristics: * * <p>If the <code>mimeType</code> is "application/x-java-serialized-object; * class=<representation class>", the result is the same as calling <code> * new DataFlavor(Class:forName(<representation class>)</code>. * * <p>Otherwise: * * <pre> * representationClass = InputStream * mimeType = mimeType * </pre> * * @param mimeType the string used to identify the MIME type for this flavor; if the the <code> * mimeType</code> does not specify a "class=" parameter, or if the class is not successfully * loaded, then an <code>IllegalArgumentException</code> is thrown * @param humanPresentableName the human-readable string used to identify this flavor; if this * parameter is <code>null</code> then the value of the the MIME Content Type is used * @exception IllegalArgumentException if <code>mimeType</code> is invalid or if the class is not * successfully loaded * @exception NullPointerException if <code>mimeType</code> is null */ public DataFlavor(String mimeType, String humanPresentableName) { super(); if (mimeType == null) { throw new NullPointerException("mimeType"); } try { initialize(mimeType, humanPresentableName, this.getClass().getClassLoader()); } catch (MimeTypeParseException mtpe) { throw new IllegalArgumentException("failed to parse:" + mimeType); } catch (ClassNotFoundException cnfe) { throw new IllegalArgumentException("can't find specified class: " + cnfe.getMessage()); } }
/** * @param resetPerfLogger * @return Tries to return an instance of the class whose name is configured in * hive.exec.perf.logger, but if it can't it just returns an instance of the base PerfLogger * class */ public PerfLogger getPerfLogger(boolean resetPerfLogger) { if ((perfLogger == null) || resetPerfLogger) { try { perfLogger = (PerfLogger) ReflectionUtils.newInstance( conf.getClassByName(conf.getVar(ConfVars.HIVE_PERF_LOGGER)), conf); } catch (ClassNotFoundException e) { LOG.error("Performance Logger Class not found:" + e.getMessage()); perfLogger = new PerfLogger(); } } return perfLogger; }
/** * Returns the live methods of a program whose root methods are the <tt>main</tt> method of a set * of classes. * * @param classes Names of classes containing root methods * @param context Repository for accessing BLOAT stuff * @return The <tt>MemberRef</tt>s of the live methods */ private static Collection liveMethods(final Collection classes, final BloatContext context) { // Determine the roots of the call graph final Set roots = new HashSet(); Iterator iter = classes.iterator(); while (iter.hasNext()) { final String className = (String) iter.next(); try { final ClassEditor ce = context.editClass(className); final MethodInfo[] methods = ce.methods(); for (int i = 0; i < methods.length; i++) { final MethodEditor me = context.editMethod(methods[i]); if (!me.name().equals("main")) { continue; } BloatBenchmark.tr(" Root " + ce.name() + "." + me.name() + me.type()); roots.add(me.memberRef()); } } catch (final ClassNotFoundException ex1) { BloatBenchmark.err.println("** Could not find class: " + ex1.getMessage()); System.exit(1); } } if (roots.isEmpty()) { BloatBenchmark.err.print("** No main method found in classes: "); iter = classes.iterator(); while (iter.hasNext()) { final String name = (String) iter.next(); BloatBenchmark.err.print(name); if (iter.hasNext()) { BloatBenchmark.err.print(", "); } } BloatBenchmark.err.println(""); } context.setRootMethods(roots); final CallGraph cg = context.getCallGraph(); final Set liveMethods = new TreeSet(new MemberRefComparator()); liveMethods.addAll(cg.liveMethods()); return (liveMethods); }
static { // FIXME: RMIServerImpl_Stub is generated at build time // after jconsole is built. We need to investigate if // the Makefile can be fixed to build jconsole in the // right order. As a workaround for now, we dynamically // load RMIServerImpl_Stub class instead of statically // referencing it. Class<? extends Remote> serverStubClass = null; try { serverStubClass = Class.forName(rmiServerImplStubClassName).asSubclass(Remote.class); } catch (ClassNotFoundException e) { // should never reach here throw (InternalError) new InternalError(e.getMessage()).initCause(e); } rmiServerImplStubClass = serverStubClass; }
public static void updateKvalification() { try { DBClass db2 = new DBClass(); ArrayList<Kvalification> k = db2.kvalificationFromDB(); comboBox_kvalification.removeAllItems(); for (int i = 0; i < k.size(); i++) { comboBox_kvalification.addItem(k.get(i)); } } catch (ClassNotFoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.getMessage()); } catch (SQLException ee) { ee.printStackTrace(); JOptionPane.showMessageDialog(null, ee.getMessage()); } }
protected void checkAssignment(Stmt.Assignment def) { checkExpression(def.lhs()); checkExpression(def.rhs()); Type lhs_t = def.lhs().attribute(Type.class); Type rhs_t = def.rhs().attribute(Type.class); try { if (!types.subtype(lhs_t, rhs_t, loader)) { ErrorHandler.handleTypeMismatch( new TypeMismatchException(def.rhs(), lhs_t, loader, types), def.rhs().attribute(SourceLocation.class)); } } catch (ClassNotFoundException ex) { syntax_error(ex.getMessage(), def); } }
public static void updateDoljnost() { try { DBClass db = new DBClass(); ArrayList<Doljnost> d = db.doljnostFromDB(); comboBox_doljnost.removeAllItems(); for (int i = 0; i < d.size(); i++) { comboBox_doljnost.addItem(d.get(i)); } } catch (ClassNotFoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, e.getMessage()); } catch (SQLException ee) { ee.printStackTrace(); JOptionPane.showMessageDialog(null, ee.getMessage()); } }
private void handleSendCode() { Connection c = null; GeneticCode code; try { netCode = ois.readInt(); c = checkConnectionNetCode(); if (c != null && c.getState() == Connection.STATE_CONNECTED) { oos.writeInt(WAITING_CODE); oos.flush(); System.out.println("->WAITING_CODE"); // $NON-NLS-1$ code = (GeneticCode) ois.readObject(); System.out.println("Genetic code"); // $NON-NLS-1$ oos.writeInt(CODE_RECEIVED); oos.flush(); System.out.println("->CODE_RECEIVED"); // $NON-NLS-1$ c.getInCorridor().receiveOrganism(code); } else { System.out.println("->NOT_CONNECTED"); // $NON-NLS-1$ oos.writeInt(NOT_CONNECTED); oos.flush(); } } catch (IOException e) { System.out.println("handleSendCode: " + e.getMessage()); // $NON-NLS-1$ if (c != null) { c.setState(Connection.STATE_DISCONNECTED); System.out.println( "Connection closed with " + c.getRemoteAddress() + //$NON-NLS-1$ ":" + c.getRemotePort()); // $NON-NLS-1$ } } catch (ClassNotFoundException e) { System.out.println("handleSendCode: " + e.getMessage()); // $NON-NLS-1$ if (c != null) { c.setState(Connection.STATE_DISCONNECTED); System.out.println( "Connection closed with " + c.getRemoteAddress() + //$NON-NLS-1$ ":" + c.getRemotePort()); // $NON-NLS-1$ } } }
public void stop(String nsr_id) { log.debug("Stopping ExecutionTask for all VNFRs of NSR with id: " + nsr_id); NetworkServiceRecord nsr = null; try { nsr = nfvoRequestor.getNetworkServiceRecordAgent().findById(nsr_id); } catch (SDKException e) { log.error(e.getMessage(), e); } catch (ClassNotFoundException e) { log.error(e.getMessage(), e); } if (nsr != null && nsr.getVnfr() != null) { for (VirtualNetworkFunctionRecord vnfr : nsr.getVnfr()) { stop(nsr_id, vnfr.getId()); } } log.info("Stopped all ExecutionTasks for NSR with id: " + nsr_id); }
protected void checkTryCatchBlock(Stmt.TryCatchBlock block) { checkBlock(block); checkBlock(block.finaly()); for (final Stmt.CatchBlock cb : block.handlers()) { checkBlock(cb); try { if (!types.subtype(JAVA_LANG_THROWABLE, cb.type().attribute(Type.class), loader)) { // This is a unique case - no substitution can be found by reflection // (as the error is within the actual source code text), so we make a generic // suggestion syntax_error("Syntax Error: Exception type must extend java.lang.Throwable", cb.type()); } } catch (ClassNotFoundException ex) { syntax_error(ex.getMessage(), block); } } }
@Override public void update(DeptVO deptVO) { Connection con = null; PreparedStatement pstmt = null; try { Class.forName(driver); con = DriverManager.getConnection(url, userid, passwd); pstmt = con.prepareStatement(UPDATE); pstmt.setString(1, deptVO.getDname()); pstmt.setString(2, deptVO.getLoc()); pstmt.setInt(3, deptVO.getDeptno()); pstmt.executeUpdate(); // Handle any driver errors } catch (ClassNotFoundException e) { throw new RuntimeException("Couldn't load database driver. " + e.getMessage()); // Handle any SQL errors } catch (SQLException se) { throw new RuntimeException("A database error occured. " + se.getMessage()); // Clean up JDBC resources } finally { if (pstmt != null) { try { pstmt.close(); } catch (SQLException se) { se.printStackTrace(System.err); } } if (con != null) { try { con.close(); } catch (Exception e) { e.printStackTrace(System.err); } } } }
// Вид формы при изменении сотрудника public void sotrDiaUpdate(Sotrudnik s) { label_id_hidden.setText(Integer.toString(s.getId_sotrudnika())); textField_familiya.setText(s.getFamiliya()); textField_imya.setText(s.getImya()); textField_otchestvo.setText(s.getOtchestvo()); textField_phone.setText(s.getPhone()); textField_date.setText(s.getData_priema().toString()); comboBox_doljnost.removeAllItems(); comboBox_kvalification.removeAllItems(); try { DBClass db = new DBClass(); ArrayList<Doljnost> d = db.doljnostFromDB(); DBClass db2 = new DBClass(); Doljnost dd = db2.doljnostFromDB(s); for (int i = 0; i < d.size(); i++) { comboBox_doljnost.addItem(d.get(i)); Doljnost ddd = (Doljnost) comboBox_doljnost.getItemAt(i); if (dd.getNazvanie_doljnosti().equals(ddd.getNazvanie_doljnosti())) dd = ddd; } comboBox_doljnost.setSelectedItem(dd); DBClass db3 = new DBClass(); ArrayList<Kvalification> k = db3.kvalificationFromDB(); DBClass db4 = new DBClass(); Kvalification kk = db4.kvalificationFromDB(s); for (int i = 0; i < k.size(); i++) { comboBox_kvalification.addItem(k.get(i)); Kvalification kkk = (Kvalification) comboBox_kvalification.getItemAt(i); if (kk.getNazvanie_kvalification().equals(kkk.getNazvanie_kvalification())) kk = kkk; } comboBox_kvalification.setSelectedItem(kk); } catch (ClassNotFoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog(panelException, e.getMessage()); } catch (SQLException ee) { ee.printStackTrace(); JOptionPane.showMessageDialog(panelException, ee.getMessage()); } }
protected void checkField(JavaField d) { checkExpression(d.initialiser()); Type lhs_t = d.type().attribute(Type.class); if (d.initialiser() != null) { Type rhs_t = d.initialiser().attribute(Type.class); try { if (!types.subtype(lhs_t, rhs_t, loader)) { ErrorHandler.handleTypeMismatch( new TypeMismatchException(d.initialiser(), lhs_t, loader, types), d.initialiser().attribute(SourceLocation.class)); } } catch (ClassNotFoundException ex) { syntax_error(ex.getMessage(), d); } } }
// Вид формы при добавлении нового сотрудника public void sotrDiaInsert() { label_id_hidden.setText("Новый сотрудник"); textField_familiya.setText(""); textField_imya.setText(""); textField_otchestvo.setText(""); textField_phone.setText(""); comboBox_doljnost.removeAllItems(); comboBox_kvalification.removeAllItems(); Calendar calend = Calendar.getInstance(); if (calend.get(Calendar.MONTH) <= 9) { textField_date.setText( String.valueOf( (calend.get(Calendar.YEAR) + "-" + ("0" + (1 + calend.get(Calendar.MONTH))) + "-") + (calend.get(Calendar.DATE)))); } else textField_date.setText( String.valueOf( ((calend.get(Calendar.YEAR)) + "-" + (1 + calend.get(Calendar.MONTH)) + "-") + (calend.get(Calendar.DATE)))); textField_date.setEnabled(false); try { DBClass db = new DBClass(); ArrayList<Doljnost> d = db.doljnostFromDB(); for (int i = 0; i < d.size(); i++) { comboBox_doljnost.addItem(d.get(i)); } DBClass db2 = new DBClass(); ArrayList<Kvalification> k = db2.kvalificationFromDB(); for (int i = 0; i < k.size(); i++) { comboBox_kvalification.addItem(k.get(i)); } } catch (ClassNotFoundException e) { e.printStackTrace(); JOptionPane.showMessageDialog(panelException, e.getMessage()); } catch (SQLException ee) { ee.printStackTrace(); JOptionPane.showMessageDialog(panelException, ee.getMessage()); } }
protected void checkCast(Expr.Cast e) { Type e_t = e.expr().attribute(Type.class); Type c_t = e.type().attribute(Type.class); try { if (e_t instanceof Type.Clazz && c_t instanceof Type.Clazz) { Clazz c_c = loader.loadClass((Type.Clazz) c_t); Clazz e_c = loader.loadClass((Type.Clazz) e_t); // the trick here, is that javac will never reject a cast // between an interface and a class or interface. However, if we // have a cast from one class to another class, then it will // reject this if neither is a subclass of the other. if (c_c.isInterface() || e_c.isInterface()) { // cast cannot fail here. return; } } else if ((e_t instanceof Type.Variable || e_t instanceof Type.Wildcard) && c_t instanceof Type.Reference) { // javac always lets this pass, no matter what return; } if (types.boxSubtype(c_t, e_t, loader) || types.boxSubtype(e_t, c_t, loader)) { // this is OK return; } else if (c_t instanceof Type.Primitive && e_t instanceof Type.Primitive) { if (e_t instanceof Type.Char && (c_t instanceof Type.Byte || c_t instanceof Type.Short)) { return; } else if (c_t instanceof Type.Char && (e_t instanceof Type.Byte || e_t instanceof Type.Short)) { return; } } ErrorHandler.handleTypeMismatch( new TypeMismatchException(e.expr(), c_t, loader, types), e.attribute(SourceLocation.class)); } catch (ClassNotFoundException ex) { syntax_error(ex.getMessage(), e); } }
public void loadScoreFile() { try { inputStream = new ObjectInputStream(new FileInputStream(HIGHSCORE_FILE)); scores = (ArrayList<Score>) inputStream.readObject(); } catch (FileNotFoundException e) { System.out.println("[Laad] FNF Error: " + e.getMessage()); } catch (IOException e) { System.out.println("[Laad] IO Error: " + e.getMessage()); } catch (ClassNotFoundException e) { System.out.println("[Laad] CNF Error: " + e.getMessage()); } finally { try { if (outputStream != null) { outputStream.flush(); outputStream.close(); } } catch (IOException e) { System.out.println("[Laad] IO Error: " + e.getMessage()); } } }
public void ejecutarReporte(String codigo) { try { cn = Conexion.realizarConexion(); String master = System.getProperty("user.dir") + "\\src\\reportes\\reporteEmpleado.jasper"; System.out.println("master: " + master); if (master == null) { showMessageDialog(null, "No se encontro el archivo", "Error", 0); System.exit(2); } JasperReport masterReport = null; try { masterReport = (JasperReport) JRLoader.loadObject(master); } catch (JRException ex) { showMessageDialog(null, "MasterReport:" + ex.getMessage(), "Error", 0); System.exit(3); } Map parametro = new HashMap(); parametro.put("chr_emplcodigo", codigo); JasperPrint jasperPrint = JasperFillManager.fillReport(masterReport, parametro, cn); JasperViewer jviewer = new JasperViewer(jasperPrint, false); jviewer.setTitle("Reporte"); jviewer.setVisible(true); } catch (ClassNotFoundException ex) { showMessageDialog(null, ex.getMessage(), "Error", 0); } catch (SQLException ex) { showMessageDialog(null, ex.getMessage(), "Error", 0); } catch (Exception ex) { showMessageDialog(null, ex.getMessage(), "Error", 0); } finally { try { cn.close(); } catch (Exception ex) { showMessageDialog(null, ex.getMessage(), "Error", 0); } } }