🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: cn.comp.lang.java
1 messages
1 total messages Started by ����(��) Sat, 19 Nov 2005 09:02
ͨ��JDBC����SQL������
#265
Author: ����(��)
Date: Sat, 19 Nov 2005 09:02
38 lines
2232 bytes
������Ѿ�װ����JDBC����Ҳ����΢���µģ���������Ҳ��ȷ������
�����ǻ���������Զ�˵���ݿ⣬������ô���°���
��ʾjava.lang.ClassNotFoundException:com.microsoft.jdbc.sqlserver.SQLServerDriver

//��ԭ����

import java.sql.*;
import java.io.*;

public class TestJdbc{
	public static void main(String[] args) {
		try{
			Class.forName(
"com.microsoft.jdbc.sqlserver.SQLServerDriver" ); 
			Connection con = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://sea-bug.3322.org:1433;databaseName=pubs",
"sa", "coolnet" ); 

			Statement stmt=con.createStatement();
			ResultSet rs=stmt.executeQuery("select1 * from
jobs");
			while(rs.next()){
					System.out.print("\t��ţ�" +
rs.getString(1));
					System.out.print("\t����" +
rs.getString(2));
					System.out.print("\t�Ա�" +
rs.getString(3));
					System.out.println();
			}
			rs.close();
			stmt.close();
			con.close();
		}catch(Exception e){
		    e.printStackTrace();
		}
	}
}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads