java数据库连接及测试(sqlserver)
package com.test.util;
import java.sql.*;
public class ConnectDB {
private Connection conn=null;
private PreparedStatement pt=null;
private ResultSet rs=null;
private String uname="sa";
private String upwd="sa";
private String url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=vsktest";
public Connection getConnection() throws Exception{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
conn=DriverManager.getConnection(url, uname, upwd);
return conn;
}
public void closeDB() throws Exception{
if(rs!=null){
rs.close();
}
if(pt!=null){
pt.close();
}
if(conn!=null){
conn.close();
}
}
public static void main(String[] args) throws Exception {
Connection conn=new ConnectDB().getConnection();
PreparedStatement pt=conn.prepareStatement("select * from test");
ResultSet rs=pt.executeQuery();
while(rs.next())
{
System.out.println(rs.getString("testname"));
}
}//end main
}
相关文档:
编写一个程序,判断一个字符串是否是合法的Java标识符;
//create string
import java.util.regex.*;
public class Split {
public static void main (String[] args) {
Pattern pattern = Pattern.compile("[,]");
String[] arrStr = pattern.split("abstract,break,byte,boole ......
Java代码
import java.util.Timer;
import java.util.TimerTask;
import java.util.Timer;
import java.util.TimerTask;
Java代码
public class Test {
public static void main(String[] args) { ......
/**
* 获取服务器的web地址
* @return
*/
private String getWebPath(){
String _tempStr = Thread.currentThread().getContextClassLoader().getResource("").toString();
_tempStr=_tempStr.substring ......
问题:在存储过程中,有时会遇到比较变态的东西,如一个存储过程中有output返回值,有return返回值,还有查询的返回值TABLE,遇到这样的存储过程真是郁闷,一次性把所有的返回值取出来还真的有点麻烦。
1、 首先来看这个存储过程吧
CREATE PROCEDURE ParaTest
@paraout varchar(20) ......
1.首先是工具比如Eclipse很方便了。
2.用winrar之类的工具,把web-info目录,及跟它同级的所有目录及文件,打包成 zip文件就行了,然后把扩展名改成war!
3 Jar命令:
假定有一个Web应用:C:\myHome
myHome/WEB-INF/……
myHome/files/……
myHome/image/… ......