java连接sql server的包放在哪里的?是自己下载还是要自己编程的?
7个回答
展开全部
你好,这个是要自己另外下载的,下载地址:https://www.microsoft.com/zh-CN/download/confirmation.aspx?id=2505
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
package com.xm.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Conn {
private String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
private String url = "jdbc:sqlserver://localhost:1433;databaseName=Test";
private String user = "sa";
private String password = "sql2005";
public String getDriver() {
return driver;
}
public void setDriver(String driver) {
this.driver = driver;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
private Connection conn = null;
public Connection getConn() {
return conn;
}
public void setConn(Connection conn) {
this.conn = conn;
}
public PreparedStatement getPs() {
return ps;
}
public void setPs(PreparedStatement ps) {
this.ps = ps;
}
public ResultSet getRs() {
return rs;
}
public void setRs(ResultSet rs) {
this.rs = rs;
}
private PreparedStatement ps = null;
private ResultSet rs = null;
private Statement st = null;
public Statement getSt() {
return st;
}
public void setSt(Statement st) {
this.st = st;
}
public Connection startConn() {
try {
Class.forName(this.driver).newInstance();
conn = DriverManager.getConnection(this.url, this.user,
this.password);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
}
====================
这个是我写好的数据库连接 你在网上下载相应的数据库JAR包 然后再把数据库连接那块的用户名跟密码改了就可以用了
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Conn {
private String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
private String url = "jdbc:sqlserver://localhost:1433;databaseName=Test";
private String user = "sa";
private String password = "sql2005";
public String getDriver() {
return driver;
}
public void setDriver(String driver) {
this.driver = driver;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
private Connection conn = null;
public Connection getConn() {
return conn;
}
public void setConn(Connection conn) {
this.conn = conn;
}
public PreparedStatement getPs() {
return ps;
}
public void setPs(PreparedStatement ps) {
this.ps = ps;
}
public ResultSet getRs() {
return rs;
}
public void setRs(ResultSet rs) {
this.rs = rs;
}
private PreparedStatement ps = null;
private ResultSet rs = null;
private Statement st = null;
public Statement getSt() {
return st;
}
public void setSt(Statement st) {
this.st = st;
}
public Connection startConn() {
try {
Class.forName(this.driver).newInstance();
conn = DriverManager.getConnection(this.url, this.user,
this.password);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
}
====================
这个是我写好的数据库连接 你在网上下载相应的数据库JAR包 然后再把数据库连接那块的用户名跟密码改了就可以用了
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-09-16
展开全部
java连接数据库需要一个包--jdbc,很多地方都有下载的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
如果只是项目用就到放项目里面,不然就放在自己机器上的java里面
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询