• 关于

    串输入输出怎么看配置

    的搜索结果

问题

【Java学习全家桶】1460道Java热门问题,阿里百位技术专家答疑解惑

管理贝贝 2019-12-01 20:07:15 27612 浏览量 回答数 19

回答

@屏蔽掉吧######@ 也没经过大脑呀.######php向java靠拢,注意数据类型(严谨性)是语言完善进步的表现。 ######类型没错呀. 它是传入一个字符串类型,######主要是告诉你这里是错误的吧,不能这样用。######坐等喷子的到来。######你就是个喷子############ http://cn2.php.net/hex2bin 不想看,你可以用@抑制错误输出。 php.ini里配置error_reporting = E_ALL就意味着输出和记录所有错误信息,包括Fatal error、Warning、Notice等各种信息,php.ini配置里有详细的说明: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Error handling and logging ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This directive informs PHP of which errors, warnings and notices you would like ; it to take action for. The recommended way of setting values for this ; directive is through the use of the error level constants and bitwise ; operators. The error level constants are below here for convenience as well as ; some common settings and their meanings. ; By default, PHP is set to take action on all errors, notices and warnings EXCEPT ; those related to E_NOTICE and E_STRICT, which together cover best practices and ; recommended coding standards in PHP. For performance reasons, this is the ; recommend error reporting setting. Your production server shouldn't be wasting ; resources complaining about best practices and coding standards. That's what ; development servers and development settings are for. ; Note: The php.ini-development file has this setting as E_ALL. This ; means it pretty much reports everything which is exactly what you want during ; development and early testing. ; ; Error Level Constants: ; E_ALL - All errors and warnings (includes E_STRICT as of PHP 5.4.0) ; E_ERROR - fatal run-time errors ; E_RECOVERABLE_ERROR - almost fatal run-time errors ; E_WARNING - run-time warnings (non-fatal errors) ; E_PARSE - compile-time parse errors ; E_NOTICE - run-time notices (these are warnings which often result ; from a bug in your code, but it's possible that it was ; intentional (e.g., using an uninitialized variable and ; relying on the fact it's automatically initialized to an ; empty string) ; E_STRICT - run-time notices, enable to have PHP suggest changes ; to your code which will ensure the best interoperability ; and forward compatibility of your code ; E_CORE_ERROR - fatal errors that occur during PHP's initial startup ; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's ; initial startup ; E_COMPILE_ERROR - fatal compile-time errors ; E_COMPILE_WARNING - compile-time warnings (non-fatal errors) ; E_USER_ERROR - user-generated error message ; E_USER_WARNING - user-generated warning message ; E_USER_NOTICE - user-generated notice message ; E_DEPRECATED - warn about code that will not work in future versions ; of PHP ; E_USER_DEPRECATED - user-generated deprecation warnings ; ; Common Values: ; E_ALL (Show all errors, warnings and notices including coding standards.) ; E_ALL & ~E_NOTICE (Show all errors, except for notices) ; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.) ; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors) ; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED ; Development Value: E_ALL ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT ; http://php.net/error-reporting ######回复 @eechen : 还能去掉警告的日志? 这是下下下下策呀, 亲.######回复 @Tuesday : 你配置 error_reporting = E_ALL & ~E_WARNING 重启服务,就可以不记录 WARNING 信息。######php log日志会记录在案. 运行久了, 日志里面就全部是这种没意义的警告信息.###### 这个你觉得没意义吗? 我见过不少对执行结果不做任何判断的人。 或许应该抛个异常才能接受。 ######回复 @Tuesday : 第一,程序遇到意外的数据难道不应该记录? 第二,程序遇到意外的数据难道不应该退出? 第三,我没说过让php内置函数抛异常的话,如果很有精力的人可以修改源码重新编译。######回复 @夏涌升 : 求详细,php怎么对内置函数抛出你所谓的异常?######回复 @Tuesday : 什么叫完全没错。。。错误/异常 如果输入的十六进制字符串是奇数长数或者无效的十六进制字符串将会抛出 E_WARNING 级别的错误。 不过要是我,在这个地方我会选择抛出异常。 我不认为返回false是个好主意,如果有人在关键业务拿false去当正常结果用,结果谁都不报异常,你想想有多悲剧。######string hex2bin ( string $data ) 这是手册的说明. 传入参数是字符串, 使用方法完全没错,######如果发生错误就返回false 你如何知道具体的错误信息?动动手try一下 也不会占用你多少时间######try{ echo hex2bin('242'); } catch(Exception $e) { print_r($e); } 求测!!!!!!!!!!!!!!!!!!! php的try更蛋疼.######楼主好腻骇######异常明显比返回值更好用 ######用try试过再说.

kun坤 2020-06-05 13:21:53 0 浏览量 回答数 0

问题

程序员报错QA大分享(1)

问问小秘 2020-06-18 15:46:14 8 浏览量 回答数 1

阿里云试用中心,为您提供0门槛上云实践机会!

0元试用32+款产品,最高免费12个月!拨打95187-1,咨询专业上云建议!

问题

在Eclipse中配置Heritrix HTTP ERROR 403.10 禁止访问:配置无效

kun坤 2020-05-27 20:05:38 7 浏览量 回答数 1

问题

基础语言百问-Python

薯条酱 2019-12-01 20:12:27 56807 浏览量 回答数 30

问题

搞懂了这几点,你就学会了Web编程

技术小菜鸟 2019-12-01 21:20:38 2373 浏览量 回答数 1

问题

API常见错误码表上线-就帮你到这里了

仙游 2019-12-01 21:00:08 5576 浏览量 回答数 1

问题

MaxCompute百问集锦(持续更新20171011)

隐林 2019-12-01 20:19:23 38430 浏览量 回答数 18

回答

我看到谢了个,轻轻笑了。没别意思啊^-^,帮顶一下?谢了个~packageorg.lsqt.components.dao.dbutil;importjava.sql.CallableStatement;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.util.ArrayList;importjava.util.List;importjava.util.Properties;importjavax.naming.InitialContext;importjavax.naming.NamingException;importjavax.sql.DataSource;importorg.apache.commons.dbutils.QueryRunner;importorg.apache.commons.dbutils.handlers.ArrayListHandler;importorg.apache.commons.lang.StringUtils;importorg.apache.log4j.Logger;importorg.lsqt.components.dao.suport.DataRow;importorg.lsqt.components.dao.suport.DataSet;importorg.lsqt.components.dao.suport.DataTable;importorg.lsqt.components.dao.suport.DbHelper;importorg.lsqt.components.dao.suport.ParamType;/ <pre>   功能说明:   该执行器优先使用JNDI配置的数据源,其次才是jdbc数据源   该SQL执行器,提供简易并直接的SQL语句操作数据库.   该SQL执行器不依赖于任何第三方的数据源创建    (注:在多个service层内调用多个执行器,没有事务控制)   编写日期:2011-4-21 作者:袁Sky   历史记录 修改日期:2012-3-10 修改人:袁Sky 修改内容:   1.添加JNDI支持   2.添加存储过程执行支持 </pre> /publicclassSqlExecutor{//privatestaticfinalLoggerLOGGER=Logger.getLogger(SqlExecutor.class);//privatestaticStringUSERNAME;/**/privatestaticStringPASSWORD;//privatestaticStringURL;/**/privatestaticStringDRIVERCLASSNAME;//privatestaticStringJNDINAME;/**/privatestaticDataSourcedataSource;//privatestaticbooleanhasJndiDataSource;//privatestaticPropertiesproperties=newProperties();static{loadConfigFile();hasJndiDataSource=loadJndiDataSource();if(hasJndiDataSource==false){try{Class.forName(DRIVERCLASSNAME);}catch(ClassNotFoundExceptione){e.printStackTrace();}}}privatestaticvoidloadConfigFile(){try{<spanstyle="background-color:#E53333;">properties.load(SqlExecutor.class.getResourceAsStream("/dbconfig.properties"));LOGGER.debug(properties);USERNAME=properties.getProperty("username");PASSWORD=properties.getProperty("password");URL=properties.getProperty("url");DRIVERCLASSNAME=properties.getProperty("driverClassName");JNDINAME=properties.getProperty("jndiName");}catch(Exceptione){try{LOGGER.error("notfounddataSource'sconfigurationfile");thrownewException(e.getMessage());}catch(Exceptione1){e1.printStackTrace();}}}privatestaticbooleanloadJndiDataSource(){try{if(StringUtils.isNotEmpty(JNDINAME)){InitialContextcontext=newInitialContext();dataSource=(DataSource)context.lookup(JNDINAME);}}catch(NamingExceptione){LOGGER.warn("havenoJNDIconfigfound");returnfalse;}returnfalse;}privatestatic ConnectiongetConnection(){try{if(hasJndiDataSource){LOGGER.debug("database'sconnectionfromJNDIdataSource");returndataSource.getConnection();}else{Connectionconn=DriverManager.getConnection(URL,USERNAME,PASSWORD);LOGGER.debug("database'sconnectionfromDriverManager");returnconn;}}catch(SQLExceptione){LOGGER.debug(e);e.printStackTrace();}returnnull;}//-------------------------------------------------------------------------------/处理参数占位符字符串@paramparamValues paramValues<aclass='referer'target='_blank'>@returnprocessprocedureParamHold/privatestaticStringprocessProcedureParamHold(Object[]paramValues){StringholdString="";intholdLength=paramValues.length;for(inti=0;i<holdLength;i++){if(i!=holdLength-1){holdString="?,"+holdString;}else{holdString=holdString+"?";}}LOGGER.debug(holdString);returnholdString;}/**执行存储过程,返回结果集@paramprocedureName存储过程名称<aclass='referer'target='_blank'>@returnDataSet /publicstaticDataSetexecuteProcedure(finalStringprocedureName){finalDataSetDATASET=newDataSet();CallableStatementcstmt=null;ResultSetrs=null;Connectioncon=null;try{con=getConnection();cstmt=con.prepareCall("{call"+procedureName+"()}");booleanhasResults=cstmt.execute();while(hasResults){DataTabledt=newDataTable();rs=cstmt.getResultSet();intcolCount=rs.getMetaData().getColumnCount();while(rs.next()){DataRowrow=newDataRow();for(inti=0;i<colCount;i++){row.add(rs.getObject(i+1));}dt.add(row);}DATASET.add(dt);hasResults=cstmt.getMoreResults();}}catch(Exceptione){LOGGER.error("procedureexecutefail==>"+e.getMessage());returnnull;}finally{DbHelper.destroy(con,cstmt,rs);}returnDATASET;}/**执行只带输入参数的存储过程@paramprocedureName 存储过程名称@paramparamValues入参值<aclass='referer'target='_blank'>@returnDataSet数据集/publicstaticDataSetexecuteProcedure(finalStringprocedureName,finalObject[]paramValues){finalDataSetDATASET=newDataSet();CallableStatementcstmt=null;ResultSetrs=null;Connectioncon=null;try{con=getConnection();cstmt=con.prepareCall("{call"+procedureName+"("+processProcedureParamHold(paramValues)+")}");booleanhasResults=cstmt.execute();while(hasResults){DataTabledt=newDataTable();rs=cstmt.getResultSet();intcolCount=rs.getMetaData().getColumnCount();while(rs.next()){DataRowrow=newDataRow();for(inti=0;i<colCount;i++){row.add(rs.getObject(i+1));}dt.add(row);}DATASET.add(dt);hasResults=cstmt.getMoreResults();}}catch(Exceptione){LOGGER.error("procedureexecutefail==>"+e.getMessage());returnnull;}finally{DbHelper.destroy(con,cstmt,rs); }returnDATASET;}/存储过程调用(返回结果集+输出参数+执行系列更新语句),调用时显示指定入参和输出参数据数据类型 @paramprocedureName存储过程名称@paramparamValues入参值和输出参数的值@paramparamValueTypes储存过程入参和输出参数据的数据类型:ParamType.String待<aclass='referer'target='_blank'>@returnDataSet数据集/publicstaticDataSetexecuteProcedure(finalStringprocedureName,finalObject[]paramValues,finalint[]paramValueTypes){if(paramValues.length!=paramValueTypes.length){LOGGER.error("procedureexecutefail,Parametersandparametertypesvalue,thelengthnotequal ");returnnull;}finalDataSetDATASET=newDataSet();StringsqlHold=processProcedureParamHold(paramValues);CallableStatementcstmt=null;ResultSetrs=null;Connectioncon=null;try{con=getConnection();cstmt=con.prepareCall("{call"+procedureName+"("+sqlHold+")}");List<Integer>outputParamIndex=newArrayList<Integer>(); for(inti=0;i<paramValues.length;i++){if(paramValues[i]==ParamType.HOLDER){cstmt.registerOutParameter(i+1,paramValueTypes[i]);outputParamIndex.add(i+1);}else{cstmt.setObject(i+1,paramValues[i]);}}booleanhasResults=cstmt.execute();//处理输出参数值List<Object>outputValues=newArrayList<Object>();for(inti=0;i<outputParamIndex.size();i++){outputValues.add(cstmt.getObject(outputParamIndex.get(i)));}DATASET.setOutputParams(outputValues.toArray(newObject[outputValues.size()]));while(hasResults){DataTabledt=newDataTable();rs=cstmt.getResultSet();//---取得第一个结果集intcolCount=rs.getMetaData().getColumnCount();while(rs.next()){DataRowrow=newDataRow();for(inti=0;i<colCount;i++){row.add(rs.getObject(i+1));}dt.add(row);}DATASET.add(dt);hasResults=cstmt.getMoreResults();}}catch(Exceptione){LOGGER.error("executeprocedurefail==>"+e.getMessage());returnnull;}finally{DbHelper.destroy(con,cstmt,rs); }returnDATASET;}/**执行更新的SQL语句@paramsql<aclass='referer'target='_blank'>@return/publicstaticbooleanexecuteSql(Stringsql){QueryRunnerrun=newQueryRunner();Connectionconn=getConnection();try{returnrun.update(conn,sql)>0;}catch(SQLExceptionex){LOGGER.error("executesqlfail==>"+ex.getMessage());returnfalse;}finally{DbHelper.destroy(conn,null,null);}}publicstaticbooleanexecuteSql(Stringsql,Object[]paramValues){QueryRunnerrun=newQueryRunner();Connectionconn=getConnection();try{returnrun.update(conn,sql,paramValues)>0;}catch(SQLExceptionex){LOGGER.error("executesqlfail==>"+ex.getMessage());returnfalse;}finally{DbHelper.destroy(conn,null,null);}}/**批量执行SQL更新语句@paramsql带占位符的SQL语句@paramdataTable参数数据表格 /publicstaticbooleanexecuteSql(Stringsql,Object[][]dataTable){QueryRunnerrun=newQueryRunner();Connectionconn=getConnection();try{ returnrun.batch(conn,sql,dataTable).length>0; }catch(SQLExceptionex){LOGGER.debug("executesqlfail==>"+ex.getMessage());returnfalse;}finally{  DbHelper.destroy(conn,null,null);}}/**执行查询语句,返回二维结果集@paramsql<aclass='referer'target='_blank'>@return<aclass='referer'target='_blank'>@throwsSQLException/publicstaticList<Object[]>executeSqlQuery(Stringsql){QueryRunnerrun=newQueryRunner();Connectionconn=getConnection();try{return run.query(conn,sql,newArrayListHandler(){@OverrideprotectedObject[]handleRow(ResultSetrs)throwsSQLException{returnsuper.handleRow(rs);}});}catch(SQLExceptionex){LOGGER.error("executesqlfail==>"+ex.getMessage());returnnull;}finally{DbHelper.destroy(conn,null,null);}}/**执行带"?"占位符的查询语句,返回二维结果集@paramsql@paramparamValues<aclass='referer'target='_blank'>@return<aclass='referer'target='_blank'>@throwsSQLException/publicstaticList<Object[]>executeSqlQuery(Stringsql,Object[]paramValues){QueryRunnerrun=newQueryRunner();Connectionconn=getConnection();try{returnrun.query(conn,sql,newArrayListHandler(){@OverrideprotectedObject[]handleRow(ResultSetrs)throwsSQLException{returnsuper.handleRow(rs);}},paramValues);}catch(SQLExceptionex){LOGGER.error("executesqlfail==>"+ex.getMessage());returnnull;}finally{DbHelper.destroy(conn,null,null);}}}谢谢阿,我这个自定义加载怎么搞定那~就是读取了配置文件,怎么跟spring整合那~<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsd"><!--wicket的web框架用-->  <beanid="consoleApplication"class="org.lsqt.content.web.wicket.ConsoleApplication"/><!--spring加载xml属性配置--><beanclass="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"><propertyname="location"value="classpath:springConfig.properties"/></bean><!--common--><importresource="applicationContext-dataSource.xml"/><importresource="applicationContext-hibernate.xml"/><importresource="applicationContext-aop.xml"/><importresource="applicationContext-ehcache.xml"/><importresource="application-spring-mvc.xml"/><spanstyle="background-color:#E53333;"><context:annotation-config/><spanstyle="background-color:#E53333;">  <context:component-scanbase-package="org.lsqt"/></beans>不同myjar.jar由JDK的ApplicationClassLoader加载而你自己定义的classLoader去加载xx.jar那么在myjar中是找不到xx.jar中的东西的建议学习一下OSGi,对classLoader应用的典型好的我看看谢谢阿

爱吃鱼的程序员 2020-06-22 21:36:09 0 浏览量 回答数 0
阿里云大学 云服务器ECS com域名 网站域名whois查询 开发者平台 小程序定制 小程序开发 国内短信套餐包 开发者技术与产品 云数据库 图像识别 开发者问答 阿里云建站 阿里云备案 云市场 万网 阿里云帮助文档 免费套餐 开发者工具 企业信息查询 小程序开发制作 视频内容分析 企业网站制作 视频集锦 代理记账服务 2020阿里巴巴研发效能峰会 企业建站模板 云效成长地图 高端建站