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
}
相关文档:
//传递参数,和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 = ......
C/C++
/*
* File: main.cpp
* Author: Vicky
*
* Created on 2010年4月29日, 上午9:46
*/
#include <iostream>
using namespace std;
int maximum(int[], int);
int main(int argc, char** argv) {
// int sg[3][4] = {
int sg[][4] = {
{68, 77, 73, 86},
{87, 96, 7 ......
结合本人学习经验和网上培训机构的资料,列出java学习的顺序。
一:J2SE
○面向对象-封装、继承、多态
○内存的分析
○递归
○集合类、泛型、自动打包与解包、Annotation
○IO
○多线程、线程同步
○TCP/UDP
○AWT、事件模型、匿名类
○正则表达式
○反射机制
2:数据库(Oracle或者MySQL)
○SQL语句
......
1.首先是工具比如Eclipse很方便了。
2.用winrar之类的工具,把web-info目录,及跟它同级的所有目录及文件,打包成 zip文件就行了,然后把扩展名改成war!
3 Jar命令:
假定有一个Web应用:C:\myHome
myHome/WEB-INF/……
myHome/files/……
myHome/image/… ......