易截截图软件、单文件、免安装、纯绿色、仅160KB

如何连接SQL Server数据库(Java版)

用Java连接SQL Server2000数据库有多种方法,下面介绍其中最常用的两种(通过JDBC驱动连接数据库)。
1. 通过Microsoft的JDBC驱动连接。此JDBC驱动共有三个文件,分别是mssqlserver.jar、msutil.jar和msbase.jar,可以到微软的网站去下载(http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=en),如果你下载的是setup.exe,还需要安装它,安装后会生成上面的三个jar文件。此JDBC驱动实现了 JDBC 2.0。
驱动程序名称:com.microsoft.jdbc.sqlserver.SQLServerDriver(即下面的classforname)
数据库连接URL:jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname(即下面的url)
2. 通过JTDS JDBC Driver连接SQL Server数据库,此驱动的文件名为jtds-1.2.jar,下载路径为(http://sourceforge.net/project/showfiles.php?group_id=33291),此驱动支持Microsoft SQL Server (6.5, 7.0, 2000 和2005) 和Sybase,并且实现了JDBC3.0,是免费的。
驱动程序名称:net.sourceforge.jtds.jdbc.Driver(即下面的classforname)
数据库连接URL:jdbc:jtds:sqlserver://localhost:1433/dbname(即下面的url)
JDBC连接SQL Server数据库的Bean代码网上大把的有,下面摘录其中的一部分:(请将localhost和1433改成你实际应用中的SQL Server服务器地址和端口号,dbname改成你实际的数据库名)
import java.sql.*;
public class DatabaseConn {
 private Connection conn;
 private Statement stmt;
 private String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname";
 private String classforname = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
 private String uid = "sa";
 private String pwd = "password";
 
 public DatabaseConn(){}
 
 /**
  * <p>通过Microsoft JDBC驱动获得数据库连接</p>
  * @return Connection
  * @exception ClassNotFoundException, SQLException
  */
 public Connection getConnection()
 {
  try
  {
   Class.forName(classforname);
   if (conn == null || conn.isClosed())
    conn = DriverMana


相关文档:

常用的SQL语句

新建表:
create table [表名]
(
[自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,
[字段1] nVarChar(50) default '默认值' null ,
[字段2] ntext null ,
[字段3] datetime,
[字段4] money null ,
[字段5] int default 0,
[字段6] Decimal (12,4) default 0,
[字段7] image null ,
)
删除表:
Drop table [表 ......

SQL SERVER 2008 正常安装失败后的集成安装

最近需要测试一个项目, 需要SQL SERVER 2008, 在微软下载评估版后进行安装
中间发现了种种安装失败的问题,对该过程进行了记录,希望给遇到此类问题的朋友们共同探讨,有所帮助:
1. WINDOWS 2003, WINDOWS 7 新装的时候可行,但是如果有删除后重新安装则无法再次安装
2. 根据网上无数先驱的失败提示, 进行了无数重试, ......

C#打包SQL数据库部署安装


参考《ASP.NET与SQL一起打包部署安装》
,这篇文章是针对VB.NET与SQL 一起打包的,但是我使用的是C#,当然只要修改一下主要安装类库就行了!C#的类库代码如下:DBCustomAction.cs
using System;
using System.Collections;
using System.Data.SqlClient;
using System.ComponentModel;
using System.Configuration.Inst ......

Top 10 Features of SQL 2008 R2

Introduction
Microsoft SQL Server 2008 R2 is the latest release of SQL Server. This article will introduce the top 10 features and benefits of SQL Server 2008 R2. The “R2” tag indicates this is an intermediate release of SQL Server and not a major revision. However, there are a number o ......

ASP.NET2.0分页技术之使用纯sql语句的双top分页篇

Repeater在前台使用比较灵活自由,但有一个问题就是Repeater不支持直接分页,这个很多人看起来就有点不想用了,但我想大家都知道GridView控件或DataGrid控件在启用自带分页的时候其实效率是非常低的,大的不说,一但到了百万级数据以后,就会感觉是多么的痛苦和无耐了,所以即使是用DataGrid(GridView)控件,高手们还是只会 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号