这是我的代码,我正在使用Java derby数据库。
package databasenew;
import java.sql.*;
public class Databasenew {
public static void main(String[] args)
{
final String Database_URL = "jdbc:derby://localhost:1527/Book";
final String SelectQuery = " SELECT fname , lname FROM Author ";
try
{
Connection conn = DriverManager.getConnection (Database_URL , "deitel","deitel");
Statement statement = conn .createStatement();
ResultSet resultst =statement.executeQuery(SelectQuery);
ResultSetMetaData metadata = resultst.getMetaData();
int nocolumn = metadata.getColumnCount();
System.out.printf("Author Table Of Books DataBase : %n %n ");
for (int i =0 ; i <= nocolumn ; i++ )
System.out.printf ("%-8s\t " , metadata.getColumnName(i)) ;
System.out.println ();
while (resultst.next())
{
for (int i =0 ; i <= nocolumn ; i++ )
System.out.printf("%-8s\t " ,resultst .getObject(i) ) ;
System.out.println ();
}
}
catch (SQLException sqlException )
{
sqlException.printStackTrace();
}
}
}
这是我尝试执行时出现的内容:
java.sql.SQLException:找不到适合的驱动程序