好久没来,过来看看

展开阅读全文

好久没来,发点感慨。

02-17

也算是CSDN的老人了……当年还当过BCB的版主,06/07年的时候转向PHP做一些自己的东西。rnrn现在主力维护的站点是https://rsywx.net。用到的基本技术是LAMP,在海外搞了个虚拟主机。其它的技术包括:Symfony, Twig, Bootstrap。还有一段时间玩过Dart。rnrn这几天比较空,上来转转,发现还是很很多年前一样,[b]重复的错误和重复的问题。[/b]rnrn最大的问题还是:[b]陈旧的用法和库的使用[/b]。rnrn很多问题中列出的代码还是所谓的vanilla PHP:PHP代码和HTML代码交错地混合在一起。我只想说,这种做法是很不好的。现在,除了纯粹的测试一个函数或者一个库,而且你确定你的这些代码不会用到后续的产品中间,我才会用这样的vanilla PHP写法。否则,我一定会用一个框架(复杂一点的用Symfony,简单一点的用Silex)。rnrn如果实在不想用框架,那么至少在调用数据库的时候,请你不要再用mysql_connect和类似的函数了,好吗?PHP已经明确表示这些函数(库)已经的过时,马上就会被停用。我们至少要用PDO吧?rnrn还有,如果方便和有精力,可以考虑用composer来组织文件依赖关系吗?——这点我也做得不是很好,不过会慢慢提高。主要是因为我用框架时,框架将这些都自动包含了,自己在编写自己的应用时,就懒得应用了。rnrn再多说几句。rnrn要当一个好的PHP程序员,英语水平还是要有一定的高度。国内的文档以讹传讹的过多,而且传达的都是一些陈旧的信息(比如上面提到的陈旧的用法和陈旧的库的使用),对初入门的开发者影响太坏。所以跑到国外的技术站点去看那些最新的技术潮流,即使不能完全弄懂,也是能帮助我们提升眼界。眼界提高了,对自己的要求也就提高了。rnrn我说这些没有别的意思,作为一个业余PHP开发者,我在Sitepoint.com上也发表过不少文章,都会讲述一些最新的技术,也学到很多新的工具的使用——比如我最近用Sami在生成API文档,用Spress在做一个静态站点。这些的讨论,我在这里没有看到,非常遗憾。rnrn我没有贬低深入PHP最基本部分的重要性。一个Symfony的Request对象,最终还是要用到get/post过来的数据,但是,如果我们能通过浏览这些成熟框架的代码,直到它如何处理这些要求,对我们写自己的代码会有巨大的帮助。是不是?rnrnrnrnrnrnrnrn 论坛

好久没来,问个问题,帮忙看一下代码:)

06-23

package com.syj.data;rnrnimport java.sql.*;rnrnpublic class DataBase rnrn Connection conn=null;rn Statement st=null;rn ResultSet rs=null;rnrn public ResultSet getRs(String query)rn tryrn Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); rn String url="jdbc:microsoft:sqlserver://172.16.244.206:1433;DatabaseName=syj"; rnrn String user="sa"; rn String password=""; rn Connection conn= DriverManager.getConnection(url,user,password); rn Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); rn rs=st.executeQuery(query);rn catch(Exception e)rn e.printStackTrace();rn rn return rs;rn rnrnrnrn错误提示:rnjava.lang.NullPointerExceptionrn at com.syjzw.data.DataBase.getRs(DataBase.java:24)rn at org.apache.jsp.index_jsp._jspService(index_jsp.java:96)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapperrn.java:210)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2rn95)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplrnicationFilterChain.java:247)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFrnilterChain.java:193)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVrnalve.java:256)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContexrnt.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.javrna:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rnrn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextVrnalve.java:191)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContexrnt.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.javrna:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rnrn at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:rn2415)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jrnava:180)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContexrnt.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatchernrValve.java:171)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContexrnt.invokeNext(StandardPipeline.java:641)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jrnava:172)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContexrnt.invokeNext(StandardPipeline.java:641)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.javrna:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rnrn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValrnve.java:174)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContexrnt.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.javrna:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rnrn at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:22rn3)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.javarn:594)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.procernssConnection(Http11Protocol.java:392)rn at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.javarn:565)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPrnool.java:619)rn at java.lang.Thread.run(Thread.java:534)rnjava.lang.NullPointerExceptionrn at org.apache.jsp.index_jsp._jspService(index_jsp.java:98)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapperrn.java:210)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:2rn95)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplrnicationFilterChain.java:247)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFrnilterChain.java:193)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperVrnalve.java:256)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContexrnt.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.javrna:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rnrn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextVrnalve.java:191)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContexrnt.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.javrna:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rnrn at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:rn2415)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.jrnava:180)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContexrnt.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatchernrValve.java:171)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContexrnt.invokeNext(StandardPipeline.java:641)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.jrnava:172)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContexrnt.invokeNext(StandardPipeline.java:641)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.javrna:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rnrn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValrnve.java:174)rn at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContexrnt.invokeNext(StandardPipeline.java:643)rn at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.javrna:480)rn at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)rnrn at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:22rn3)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.javarn:594)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.procernssConnection(Http11Protocol.java:392)rn at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.javarn:565)rn at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPrnool.java:619)rn at java.lang.Thread.run(Thread.java:534) 论坛

没有更多推荐了,返回首页