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数据库代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对编程之家网站的支持!
原文链接:https://www.f2er.com/java/66037.html