public class SqlServer
{
public static void main(String[] args)
{
try
{ Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;database=mydb;
", "user", "pass");
Statement st = conn.createStatement();
ResultSet rs=st.executeQuery("select * from aa10");
while (rs.next())
{ System.out.println(rs.getString(1));
} } catch (ClassNotFoundException e)
{ e.printStackTrace();
} catch (SQLException e)
{ e.printStackTrace();
} } }
以上所述是小編給大家介紹的Java連接sqlserver2008數(shù)據(jù)庫代碼,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!