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了
public class FunnyNumbers {
public static void main(String[] args) {
double largeNum = (int)Math.exp(4000.0);
//int 不能除0
//Exception in thread "main" java.lang.ArithmeticException: / by zeroat FunnyNumbers.main(FunnyNumbers.j ......
//传递参数,和c中传地址有点像
public class ArrayParameters {
public static void changeOrNot (int i, double[] x) {
i =-1;
x[0] = -2.0;
double[] y = x;
y[1] = -3.0;
double[] z = {4.0, 4.0, 4.0};
x = z;
}
public static void main (String[] args) {
String s1 = ......
问题:在存储过程中,有时会遇到比较变态的东西,如一个存储过程中有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/… ......