JavaÁ¬½ÓSQLServer³öÏÖÁËһЩÎÊÌâ - Java / Java SE
ÕâÊÇÎÒµÄÔ´³ÌÐò¡£
package sqltest;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class SQLtest {
public SQLtest(){
}
void display() {
Connection con=null;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=MyDB";
String userName = "sa";
String passWord = "sa";
con = DriverManager.getConnection(url, userName , passWord);
Statement stmt=con.createStatement();
int id;
String text;
int age;
ResultSet rs;
String strSQL="Seclet * from Person";
rs=stmt.executeQuery(strSQL);
if(rs.next()){
do{
id=rs.getInt(1);
System.out.print("ID:"+id);
text=rs.getString(2);
System.out.print("ÐÕÃû:"+text);
text=rs.getString(3);
System.out.print("ÐÔ±ð:"+text);
age=rs.getInt(4);
System.out.print("ÄêÁä:"+age);
text=rs.getString("address");
System.out.print("µØÖ·:"+text);
text=rs.getString("phone");
System.out.print("µç»°:"+text);
}while(rs.nex
Ïà¹ØÎÊ´ð£º
±¾ÈËÕýÔÚÓÃJava×öÒ»¸öC/S¼Ü¹¹µÄÏîÄ¿£¬
¿ÉÊÇÓÉÓÚÏîÄ¿±È½Ï´ó£¬Ç°ÆڶԼܹ¹µÄÉè¼ÆÓÈÆäÖØÒª£¬ÒòΪºóÆÚ¿ÉÄÜËæʱ»á¼Ó¸ö¹¦ÄÜ»òÕßÈ¥µôijЩ¹¦ÄÜ¡£
ËùÒÔÌصØÑ°ÇóÈçºÎÉè¼ÆC/SµÄ¼Ü¹¹Ê¹³ÌÐò¸ü¼ÓÃæÏò¶ÔÏó¸ü¼ÓÒ×ÓÚά ......
¸÷·´óÏÀ¸ø¸ö˼·£¬²»ÊÇÔÚÏßµÄÄÇÖÖ£¬¾ÍÊÇÒ»¸ö×öÆÕͨµÄÓ¦ÓóÌÐò¡£
´Ê¿âÔõôÉú³ÉÄØ£¿
²»»á¡£
ÒýÓÃ
´Ê¿âÔõôÉú³ÉÄØ£¿
ÕÒ±¾×Öµä
ÒýÓÃ
´Ê¿âÔõôÉú³ÉÄØ£¿
Êý¾Ý¿â ºÇºÇ
ÓÃmap ¼üÖµ¶ÔÓ¦
Èç¹ûÓÃÊý¾Ý¿ ......
ΪʲôHTMLÒÔ¼°Ò»Ð©ÆäËü±êÇ©»áÏÔʾһЩÌض¨±íÏÖÐÎʽÄØ£¿ÈçHTMLÖеĻ»ÐбêÇ©<BR/>ÔڵײãÊÇÔõÑùʵÏÖµÄÄØ£¿ÏÖʵµÄÔÀíÊÇʲôÄØ
È¥W3C¹Ù·½ÍøÕ¾ÉÏ£¬¿´¿´°É£¡ÎÒÏëÒ»¿´Äã¾ÍÃ÷°×ÁË
ÎҲºͱàÒëÔÀíÓйأ¬ä¯ÀÀÆ÷Àï¿É ......
ʹÓÃjavaÔÚwindows7 32λÏÂÁ¬½ÓMSSQL¡£
Á½Ì¨»úÆ÷£¬windows7 32룬ÔÚ¿ØÖÆÃæ°åÀïÃæÈ«²¿ÉèÖÃÓïÑÔºÍÇøÓòÑ¡Ïenglish-unitedstates
ΨһÇø±ðÖ»ÓÐÔÚ°²×°SQL server 2008µÄʱºò Ñ¡ÔñµÄ×Ö·û¼¯²»Ò»Ñù£¬
exec sp_helpsor ......