List of usage examples for java.lang ClassNotFoundException printStackTrace
public void printStackTrace()
From source file:org.apache.hadoop.hive.ql.metadata.BIStore.java
public Connection openConnect(int timeout) { try {//from w ww . j av a 2 s. co m Class.forName("org.postgresql.Driver"); } catch (ClassNotFoundException e) { LOG.error(" get org.postgresql.Driver failed "); e.printStackTrace(); } Connection conn = null; try { LOG.info(" Connecting: " + url); DriverManager.setLoginTimeout(timeout); this.prop.setProperty("loginTimeout", String.valueOf(timeout)); conn = DriverManager.getConnection(url, this.prop); try { String processName = java.lang.management.ManagementFactory.getRuntimeMXBean().getName(); String processID = processName.substring(0, processName.indexOf('@')); String appinfo = "openConnect_" + processID + "_" + SessionState.get().getSessionName(); conn.setClientInfo("ApplicationName", appinfo); } catch (Exception e) { e.printStackTrace(); } LOG.info(" get Connection ok: " + url); } catch (SQLException e) { LOG.error(" get Connection failed: " + url); e.printStackTrace(); } return conn; }
From source file:com.dearho.cs.appinterface.subscriber.AppSubscriberAction.java
/** * @Title: subscriberUpdate //from ww w . j a va 2 s .c o m * @Description: * @param @return * @return String * @throws */ public String subsUpdate() { String id = getRequest().getParameter("subscriber_id"); String email = getRequest().getParameter("subscriber_email"); if (StringUtils.isEmpty(id)) { result = Ajax.AppJsonResult(Constants.APP_RESULT_CODE_FAIL, "ID"); return SUCCESS; } Subscriber subs = subscriberService.querySubscriberById(id); if (Subscriber.EVENT_STATE_HALF.equals(subs.getEventState())) { result = Ajax.AppJsonResult(Constants.APP_RESULT_CODE_FAIL, "?????"); return SUCCESS; } if (!StringUtils.isEmpty(email)) { String check = "^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+"; Pattern regex = Pattern.compile(check); Matcher m = regex.matcher(email); if (!m.matches()) { result = Ajax.AppJsonResult(Constants.APP_RESULT_CODE_FAIL, "?"); return SUCCESS; } } Object beforeObject = subscriberService.querySubscriberById(subs.getId()); String city = getRequest().getParameter("subscriber_city"); String province = getRequest().getParameter("subscriber_province"); String county = getRequest().getParameter("subscriber_county"); String address = getRequest().getParameter("subscriber_address"); String emergencyContact = getRequest().getParameter("subscriber_emergencyContact"); String emergencyContactAddress = getRequest().getParameter("subscriber_emergencyContactAddress"); String emergencyContactPhone = getRequest().getParameter("subscriber_emergencyContactPhone"); subs.setCity(city); subs.setProvince(province); subs.setCounty(county); subs.setAddress(address); subs.setEmail(email); subs.setEmergencyContact(emergencyContact); subs.setEmergencyContactAddress(emergencyContactAddress); subs.setEmergencyContactPhone(emergencyContactPhone); subscriberService.updateSubscriber(subs); Object afterObject = subs; result = Ajax.AppJsonResult(Constants.APP_RESULT_CODE_SUCCESS, "?"); try { SystemOperateLogUtil.sysUpdateOperateLog(beforeObject, afterObject, null, SystemOperateLogUtil.MODEL_SUBSCRIBER_INFO, subs.getName()); } catch (ClassNotFoundException e) { e.printStackTrace(); } return SUCCESS; }
From source file:imageviewer.system.ImageViewerClient.java
private void verifyJAI() { // JAI Detection boolean dllPassFlag = false; try {/* ww w. j ava 2s .c o m*/ Class.forName("javax.media.jai.JAI"); } catch (ClassNotFoundException exc) { JFrame frame = new JFrame("mii imageviewer"); JOptionPane.showMessageDialog(frame, "JAI is not installed on this machine. Please install."); exc.printStackTrace(); System.exit(1); } // JAI DLL Detection try { System.load(System.getProperty("java.home") + "/bin/mlib_jai.dll"); dllPassFlag = true; } catch (Exception exc) { dllPassFlag = false; } catch (UnsatisfiedLinkError exc22) { dllPassFlag = false; } // Don't ever check for *.so objects! Breaks things on Linux! -gsw if (dllPassFlag == false) { LOG.error("Missing JAI DLL or system libraries."); } else { LOG.info("Java Advanced Imaging (JAI) version: " + JAI.getBuildVersion()); } }
From source file:at.flack.FacebookMainActivity.java
public String loadCookie() throws StreamCorruptedException, FileNotFoundException, IOException { if (getActivity() == null) return ""; ObjectInputStream inputStream = null; String erg = null;// w w w . j av a2s.c o m try { inputStream = new ObjectInputStream( new FileInputStream(new File(getActivity().getFilesDir(), "cookie.dat"))); erg = (String) inputStream.readObject(); } catch (ClassNotFoundException e) { } finally { try { if (inputStream != null) inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } return erg; }
From source file:coral.data.DataServiceJbdcImpl.java
public DataServiceJbdcImpl(String dbname, boolean setup, String dbmode) { // Load the HSQL Database Engine JDBC driver // hsqldb.jar should be in the class path or made part of the current // jar/*w w w . j a v a2 s .c o m*/ try { Class.forName("org.hsqldb.jdbcDriver"); // connect to the database. This will load the db files and start // the // database if it is not already running. // db_file_name_prefix is used to open or create files that hold the // state // of the db. // It can contain directory names relative to the // current working directory conn = DriverManager.getConnection("jdbc:hsqldb:" + dbmode + ":" + dbname + "/exp.db", // filenames "sa", // username ""); if (dbmode.equals("mem") || setup) { logger.info("SETUP DATABASE"); Statement stat = conn.createStatement(); // stat.execute("delete from datas;"); // stat.execute("delete from states;"); stat.execute("drop table if exists datas;"); stat.execute( "CREATE TABLE datas ( id BIGINT, collection VARCHAR(10), name VARCHAR(80), value VARCHAR(1024));"); stat.execute("CREATE INDEX idatas ON datas ( id, name );"); stat.execute("drop table if exists states;"); stat.execute( "CREATE TABLE states ( id BIGINT, collection VARCHAR(10), template VARCHAR(80), block INTEGER, round INTEGER, stage INTEGER, msg VARCHAR(255));"); stat.execute("COMMIT"); conn.commit(); stat.close(); } } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } }
From source file:cai.flow.packets.V9_Packet.java
/** * UDPflowsVector/*from w ww . jav a2s. com*/ * * @param RouterIP * @param buf * @param len * @throws DoneException */ @SuppressWarnings("unchecked") public V9_Packet(String RouterIP, byte[] buf, int len) throws DoneException { if (Params.DEBUG) { // // File tmpFile = new File("D:\\Dev\\netflow\\jnca\\savePacketT_211.98.0.147_256.cache.tmp"); File tmpFile = new File("D:\\Dev\\netflow\\jnca\\savePacketT_211.98.0.147_256.cache.tmp"); if (tmpFile.exists()) { try { ObjectInputStream fIn = new ObjectInputStream(new FileInputStream(tmpFile)); System.out.println("Directly read from " + fIn); try { buf = (byte[]) fIn.readObject(); len = ((Integer) fIn.readObject()).intValue(); } catch (ClassNotFoundException e) { e.printStackTrace(); } fIn.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else { try { ObjectOutputStream fOut; fOut = new ObjectOutputStream(new FileOutputStream(tmpFile)); fOut.writeObject(buf); fOut.writeObject(new Integer(len)); fOut.flush(); fOut.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } // } if (len < V9_Header_Size) { throw new DoneException(" * incomplete header *"); } this.routerIP = RouterIP; count = Util.to_number(buf, 2, 2); // (template data flowset SysUptime = Util.to_number(buf, 4, 4); Variation vrat = Variation.getInstance(); vrat.setVary(Util.convertIPS2Long(RouterIP), SysUptime); unix_secs = Util.to_number(buf, 8, 4); packageSequence = Util.to_number(buf, 12, 4); sourceId = Util.to_number(buf, 16, 4); flows = new Vector((int) count * 30); // Let's first make some space optionFlows = new Vector(); // t long flowsetLength = 0l; // flowset for (int flowsetCounter = 0, packetOffset = V9_Header_Size; flowsetCounter < count && packetOffset < len; flowsetCounter++, packetOffset += flowsetLength) { // flowset long flowsetId = Util.to_number(buf, packetOffset, 2); flowsetLength = Util.to_number(buf, packetOffset + 2, 2); if (flowsetLength == 0) { throw new DoneException("there is a flowset len=0packet invalid"); } if (flowsetId == 0) { // template flowsettemplateiddata flowset // template flowset int thisTemplateOffset = packetOffset + 4; do { // template long templateId = Util.to_number(buf, thisTemplateOffset, 2); long fieldCount = Util.to_number(buf, thisTemplateOffset + 2, 2); if (TemplateManager.getTemplateManager().getTemplate(this.routerIP, (int) templateId) == null || Params.v9TemplateOverwrite) { try { TemplateManager.getTemplateManager().acceptTemplate(this.routerIP, buf, thisTemplateOffset); } catch (Exception e) { if (Params.DEBUG) { e.printStackTrace(); } if ((e.toString() != null) && (!e.toString().equals(""))) { if (e.toString().startsWith("savePacket")) { try { ObjectOutputStream fOut; fOut = new ObjectOutputStream( new FileOutputStream("./" + e.toString() + ".cache.tmp")); fOut.writeObject(buf); fOut.writeObject(new Integer(len)); fOut.flush(); fOut.close(); System.err.println("Saved "); } catch (FileNotFoundException e2) { e2.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } else { System.err.println("An Error without save:" + e.toString()); } } } } thisTemplateOffset += fieldCount * 4 + 4; // } while (thisTemplateOffset - packetOffset < flowsetLength); } else if (flowsetId == 1) { // options flowset continue; // int thisOptionTemplateOffset = packetOffset + 4; // // bypass flowsetID and flowset length // do { // // template // long optionTemplateId = Util.to_number(buf, // thisOptionTemplateOffset, 2); // long scopeLen = Util.to_number(buf, // thisOptionTemplateOffset + 2, 2); // long optionLen = Util.to_number(buf, // thisOptionTemplateOffset + 4, 2); // if (OptionTemplateManager.getOptionTemplateManager() // .getOptionTemplate(this.routerIP, // (int) optionTemplateId) == null // || Params.v9TemplateOverwrite) { // OptionTemplateManager.getOptionTemplateManager() // .acceptOptionTemplate(this.routerIP, buf, // thisOptionTemplateOffset); // } // thisOptionTemplateOffset += scopeLen + optionLen + 6; // } while (thisOptionTemplateOffset - // packetOffset < flowsetLength); } else if (flowsetId > 255) { // data flowset // templateId==flowsetId Template tOfData = TemplateManager.getTemplateManager().getTemplate(this.routerIP, (int) flowsetId); // flowsetId==templateId if (tOfData != null) { int dataRecordLen = tOfData.getTypeOffset(-1); // // packetOffset+4 flowsetId length for (int idx = 0, p = packetOffset + 4; (p - packetOffset + dataRecordLen) < flowsetLength; //consider padding idx++, p += dataRecordLen) { //+5 makes OK // IP?v9v5 V5_Flow f; try { f = new V5_Flow(RouterIP, buf, p, tOfData); flows.add(f); } catch (DoneException e) { if (Params.DEBUG) { e.printStackTrace(); } if ((e.toString() != null) && (!e.toString().equals(""))) { if (e.toString().startsWith("savePacket")) { try { ObjectOutputStream fOut; fOut = new ObjectOutputStream( new FileOutputStream("./" + e.toString() + ".cache.tmp")); fOut.writeObject(buf); fOut.writeObject(new Integer(len)); fOut.flush(); fOut.close(); System.err.println("Saved "); } catch (FileNotFoundException e2) { e2.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } else { System.err.println(e.toString()); } } } } } else { //options packet, should refer to option template, not in use now continue; // OptionTemplate otOfData = OptionTemplateManager // .getOptionTemplateManager(). // getOptionTemplate( // this.routerIP, (int) flowsetId); // if (otOfData != null) { // int dataRecordLen = otOfData.getTypeOffset( -1); // // // packetOffset+4 flowsetId length // for (int idx = 0, p = packetOffset + 4; p // - packetOffset < flowsetLength; // idx++, p += dataRecordLen) { // OptionFlow of; // try { // of = new OptionFlow(RouterIP, buf, p, otOfData); //// optionFlows.add(of); // Vector // } catch (DoneException e) { // if (Params.DEBUG) { // e.printStackTrace(); // } // System.err.println(e.toString()); // } // } // } else { // System.err.println(this.routerIP + "" + flowsetId // + "template"); // } } } } }
From source file:fr.cobaltians.cobalt.activities.CobaltActivity.java
public void popTo(String controller, String page) { Intent popToIntent = Cobalt.getInstance(this).getIntentForController(controller, page); if (popToIntent != null) { Bundle popToExtras = popToIntent.getBundleExtra(Cobalt.kExtras); String popToActivityClassName = popToExtras.getString(Cobalt.kActivity); try {/*ww w .j ava 2 s . c o m*/ Class<?> popToActivityClass = Class.forName(popToActivityClassName); boolean popToControllerFound = false; int popToControllerIndex = -1; for (int i = sActivitiesArrayList.size() - 1; i >= 0; i--) { Activity oldActivity = sActivitiesArrayList.get(i); Class<?> oldActivityClass = oldActivity.getClass(); Bundle oldBundle = oldActivity.getIntent().getExtras(); Bundle oldExtras = (oldBundle != null) ? oldBundle.getBundle(Cobalt.kExtras) : null; String oldPage = (oldExtras != null) ? oldExtras.getString(Cobalt.kPage) : null; if (oldPage == null && CobaltActivity.class.isAssignableFrom(oldActivityClass)) { Fragment fragment = ((CobaltActivity) oldActivity).getSupportFragmentManager() .findFragmentById(((CobaltActivity) oldActivity).getFragmentContainerId()); if (fragment != null) { oldExtras = fragment.getArguments(); oldPage = (oldExtras != null) ? oldExtras.getString(Cobalt.kPage) : null; } } if (popToActivityClass.equals(oldActivityClass) && (!CobaltActivity.class .isAssignableFrom(oldActivityClass) || (CobaltActivity.class.isAssignableFrom(oldActivityClass) && page.equals(oldPage)))) { popToControllerFound = true; popToControllerIndex = i; break; } } if (popToControllerFound) { while (popToControllerIndex + 1 <= sActivitiesArrayList.size()) { sActivitiesArrayList.get(popToControllerIndex + 1).finish(); } } else if (Cobalt.DEBUG) Log.w(Cobalt.TAG, TAG + " - popTo: controller " + controller + (page == null ? "" : " with page " + page) + " not found in history. Abort."); } catch (ClassNotFoundException exception) { exception.printStackTrace(); } } else if (Cobalt.DEBUG) Log.e(Cobalt.TAG, TAG + " - popTo: unable to pop to null controller"); }
From source file:assignment3.Populate.java
Createcheckin() { try {/*w ww.j ava 2 s . com*/ Class.forName("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e) { System.out.println("JDBC Driver Missing"); e.printStackTrace(); return; } System.out.println("Oracle JDBC Driver Connected"); Connection conn = null; PreparedStatement ps = null; try { conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "MAYUR", "123456"); JSONParser parser = new JSONParser(); BufferedReader br = new BufferedReader(new FileReader( "C:\\Users\\mayur\\Downloads\\YelpDataset\\YelpDataset-CptS451\\yelp_checkin.json")); //BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\mayur\\Downloads\\YelpDataset\\YelpDataset-CptS451\\checkinsmall.json")); int batch = 50; int count = 0; String sCurrentLine = ""; String temp = ""; while ((sCurrentLine = br.readLine()) != null) { conn.setAutoCommit(false); Object obj = parser.parse(sCurrentLine); JSONObject t = (JSONObject) obj; String type = t.get("type").toString(); String business_id = t.get("business_id").toString(); JSONObject checkinInfo = (JSONObject) t.get("checkin_info"); // get all votes details ps = conn.prepareStatement("insert into checkin values (?, ?, ?,?,?)"); ps.setString(4, business_id); ps.setString(5, type); for (int i = 0; i < 7; i++) { for (int j = 0; j < 24; j++) { String temp_key = j + "-" + i; if (checkinInfo.containsKey(temp_key)) { long num_checkin = (long) checkinInfo.get(temp_key); //i - day //j - time //num checkin - number //Insert ps.setLong(1, (long) j); // hours ps.setLong(2, (long) i); //day ps.setLong(3, num_checkin); ps.executeUpdate(); } } } count++; System.out.println("Record Number :" + count); if (count % batch == 0) { conn.commit(); ps.close(); conn.close(); conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "MAYUR", "123456"); } } System.out.println("Record inserted Finally in Checkin Table " + count); conn.commit(); ps.close(); conn.close(); } catch (Exception e) { System.out.println("Connection Failed! Check output console"); e.printStackTrace(); return; } finally { try { ps.close(); conn.close(); } catch (Exception e) { } } }
From source file:assignment3.Populate.java
CreateUser() { try {//w w w .j av a 2 s . com Class.forName("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e) { System.out.println("JDBC Driver Missing"); e.printStackTrace(); return; } System.out.println("Oracle JDBC Driver Connected"); Connection conn = null; try { conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "MAYUR", "123456"); conn.setAutoCommit(false); PreparedStatement ps = conn .prepareStatement("insert into yelp_user values (?, ?, ?,?, ?, ?,?, ?, ?,?,?)"); JSONParser parser = new JSONParser(); Object obj = parser.parse(new BufferedReader(new FileReader( "C:\\Users\\mayur\\Downloads\\YelpDataset\\YelpDataset-CptS451\\yelp_user.json"))); //Object obj = parser.parse(new BufferedReader(new FileReader("C:\\Users\\mayur\\Downloads\\YelpDataset\\YelpDataset-CptS451\\yelp_user1.json"))); JSONArray jsonArray = (JSONArray) (obj); // JSONArray jsonArray = (JSONArray)(obj1); for (int i = 0; i < jsonArray.size(); i++) { JSONObject t = (JSONObject) jsonArray.get(i); String c = t.get("yelping_since").toString(); Date yelping_since = (Date) java.sql.Date.valueOf(c + "-01"); JSONObject votes = (JSONObject) t.get("votes"); // get all votes details Long votes_funny = (Long) votes.get("funny"); Long votes_useful = (Long) votes.get("useful"); Long votes_cool = (Long) votes.get("cool"); Long review_count = (Long) t.get("review_count"); String name = t.get("name").toString(); String user_id = t.get("user_id").toString(); JSONArray friends = (JSONArray) (t).get("friends"); int numfriends = 0; if (friends != null) { Iterator<String> iterator = friends.iterator(); ArrayList<String> friendid_list = new ArrayList<String>(); while (iterator.hasNext()) { friendid_list.add(iterator.next()); } if (friendid_list != null) numfriends = friendid_list.size(); friendid_list = null; iterator = null; } Long fans = (Long) t.get("fans"); double average_stars = (double) t.get("average_stars"); String type = t.get("type").toString(); ps.setDate(1, yelping_since); ps.setLong(2, votes_funny); ps.setLong(3, votes_useful); ps.setLong(4, votes_cool); ps.setLong(5, review_count); ps.setString(6, name); ps.setString(7, user_id); ps.setLong(8, fans); ps.setDouble(9, average_stars); ps.setString(10, type); ps.setInt(11, numfriends); ps.executeUpdate(); System.out.println("Record inserted " + i); } conn.commit(); ps.close(); } catch (Exception e) { System.out.println("Connection Failed! Check output console"); e.printStackTrace(); return; } }
From source file:com.ycdyng.onemulti.OneActivity.java
private Fragment getFragment(String className) { Class cls = null;/* w ww . jav a 2 s . c o m*/ try { cls = Class.forName(className); } catch (ClassNotFoundException e) { e.printStackTrace(); throw new IllegalArgumentException(className + " not found"); } try { return (Fragment) cls.newInstance(); } catch (IllegalAccessException e) { e.printStackTrace(); throw new IllegalArgumentException(className + " is inaccessible"); } catch (InstantiationException e) { e.printStackTrace(); throw new IllegalArgumentException(className + " cannot be instantiated"); } }