欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

java 联接加密access 2007

更新时间: 2014-01-05 02:25:17 责任编辑: Author_N1

 

java 连接加密access 2007

public class CRSampleDataSourceBean {
	private static ResultSet resultSet = null;
	private static Connection connection = null;
	private static String connectionURL = "jdbc:odbc:Xtreme Sample Database 11.5";

	private  static String databaseClass = "sun.jdbc.odbc.JdbcOdbcDriver";
	private  static String query = "select * from customer";

public static void main(String[] args) {
		CreateDat cd=new CreateDat();
		try {
			ResultSet rs=cd.getResultSet();
			while(rs.next()){
				System.out.println(rs.getString("Customer Name"));
			}
		} catch (SQLException e) {
			System.out.println(e.getMessage());
		}
		
	}
	
	static class CreateDat{
		public CreateDat() {
			try {
				// Ensure database class exists
				Class.forName(databaseClass);
				// Create a connection
				connection = DriverManager.getConnection(connectionURL, "", "");
			} catch (ClassNotFoundException ex) {
				System.out
						.println("Ensure that database driver class is installed.");
				ex.printStackTrace();
			} catch (SQLException ex) {
				System.out.println("SQL Exception #" + ex.getErrorCode() + " : "
						+ ex.getLocalizedMessage());
				ex.printStackTrace();
			}
		}

		/*
		 * Any function that returns a java.sql.ResultSet within the Java class can
		 * be used in Crystal Reports to return report data. The function can also
		 * be parameterized to 'feed' in specific values to the function when
		 * querying.
		 */
		public ResultSet getResultSet() throws SQLException {
			// Create an SQL statement to execute
			Statement statement = connection.createStatement(
					ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
			// Execute the select statement to populate the ResultSet
			resultSet = statement.executeQuery(query);
			return resultSet;
		}
	}
上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 02:25:17
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/9587/
本文WWW.DOC100.NET DOC100.NET版权所有。