我的 Access 数据库有一个表,其中有一列包含旁遮普语文本。我正在尝试使用 JDBC 从 Java (NetBeans) 处理该数据库。
我的代码是:
private void b1ActionPerformed(java.awt.event.ActionEvent evt)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + "D:\\PP.accdb";
Connection conn = DriverManager.getConnection(url);
System.out.println("Connection Successful");
Statement stmt = conn.createStatement();
stmt.execute("select * from Emp");
ResultSet rs = stmt.getResultSet();
if (rs != null)
{
String s1,s2;
s1=" ";
s2=" ";
while ( rs.next() )
{
JOptionPane.showMessageDialog(null ,rs.getString(2), "Output" ,JOptionPane.INFORMATION_MESSAGE );
}
}
stmt.close();
conn.close();
}
catch (Exception err) { System.out.println("ERROR: " + err); }
}