菜鸟求教,jdbc程序中判断某个表是否存在的程序该怎么写?
这样:
select * from table_name where exists (select 1 from sysobjects where name =’tb’ and type =’u’)
exists一般是在where语句后面,表示是否存在记录,如果存在记录条数就返回true,因此用select 1 from … 是完全可以的,用exists的最主要好处是,其可以返回多条记录。
如何使用eclipse创建一个jdbc+spring+springmvc项目,本人菜鸟一枚,还望高手指教。
SpringMVC+MyBatis+Freemarker 简单框架搭建(一)一、开发环境: Eclipse、Tomcat、SVN等请参见如下的帖子,很详细了。http://www.iteye.com/topic/982182 svn和maven插件的安装: 1、先安装gef插件 地址:http://download.eclipse.org/tools/gef/updates/interim/ 2、安装svn插件 地址:http://subclipse.tigris.org/update_1.6.x 3、maven插件 m2eclipse-core Update 地址: http://m2eclipse.sonatype.org/sites/m2e m2eclipse-extras Update 地市: http://m2eclipse.sonatype.org/sites/m2e-extras 4、安装可能出现的问题 直接在线安装maven2 会出现依赖插件找不到的问题,无法安装。
必须先安装gef 插件后才能安 装m2eclipse-core 插件,然而安装m2eclipse-extras 插件又依赖subclipse 插件。
所以,三个插 件的正确的安装顺序是:gef插件 》subclipse插件 》m2eclipse插件二、web.xml 和 applicationContext.xml 配置 1、web.xml文件配置:<?xml version=”1.0″ encoding=”UTF-8″?><web-app xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”xmlns=”http://java.sun.com/xml/ns/javaee” xmlns:web=”http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd”xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd”version=”2.5″> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!– Spring MVC 配置 –> <servlet> <servlet-name>springServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:contextConfigLocation-springService.xml</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!– 事件监听器 –> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!– shiro 权限控制的过滤器 –><!– Spring 刷新Introspector防止内存泄露 –> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <!– session超时定义,单位为分钟 –> <session-config> <session-timeout>20</session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list><!– 设置servlet编码开始 –> <filter> <filter-name>Set Character Encoding</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>GB2312</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>Set Character Encoding</filter-name> <url-pattern>/</url-pattern> </filter-mapping> <!– 设置servlet编码结束 –><display-name>Archetype Created Web Application</display-name></web-app><context-param>节点和<listener>节点是web项目启动时最先读取的两个节点,所以这两个节点里面所配置的内容是web项目启动时最先加载的部分。
菜鸟问题:mysql的JDBC驱动应该放在哪
导入jdbc驱动程序包其实有很多种方法,但是不同的导包方式有不同的含义,1、给Tomcat导包(表示服务器可能要用到数据库,例如数据源),如果是MyEclipse集成Tomcat,显然是要用“右键项目- Properties – Java Build Path- 右侧选项卡选择Libraries – AddJARs…”。如果是非集成Tomcat,你必须把驱动程序包复制粘贴在Tomcat根目录“common\lib”文件夹下。
2、给Web项目导包(表示Web项目需要使用到数据库),把驱动程序包复制粘贴到“Web项目\WEB-INF\lib”文件夹下。
同时也要在Tomcat的webapps\Web项目\WEB-INF\lib文件夹中粘贴驱动程序。3、给单纯Java项目导包(表示Web项目需要使用到数据库),对着project单击右键,选择Bulid Path选择AddExternal Achieves再选择mysqljdbc.jar或者将其添加到classpath中去。