0
現在我得到了java.sql.SQLException:找不到適合jdbc的驅動程序:firebirdsql:embedded:f/test.fdbJava和Firebird嵌入式如何創建數據庫?
我在我的項目中包含jaybird jar。請幫我出去
package util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import org.firebirdsql.gds.impl.GDSType;
import org.firebirdsql.management.FBManager;
public class FireBirdCreator {
public FireBirdCreator() {
FBManager manager = new FBManager(GDSType.getType("EMBEDDED"));
try {
manager.start();
manager.createDatabase("f:/test.fdb", "sysdba", "masterkey");
manager.stop();
Connection bd = DriverManager.getConnection("jdbc:firebirdsql:embedded:f/test.fdb");
Statement st = bd.createStatement();
st.execute("create table if not exists 'TABLE1' ('name1' int, 'name2' text, 'name3' text);");
st.execute("insert into 'TABLE1' ('name1', 'name2', 'name3') values (1, 'name1', 'name2'); ");
st.execute("insert into 'TABLE1' ('name1', 'name2', 'name3') values (2, 'name3', 'name4'); ");
st.execute("insert into 'TABLE1' ('name1', 'name2', 'name3') values (3, 'name5', 'name6');");
ResultSet rs = st.executeQuery("select * from TABLE1");
while (rs.next())
{
System.out.print (rs.getString(1)+" ");
System.out.print (rs.getString(2)+" ");
System.out.println(rs.getString(3));
}
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String args[]) {
FireBirdCreator fbc = new FireBirdCreator();
}
}
您的標題暗示您想要創建數據庫,而您的代碼只能連接到數據庫。數據庫是否存在? –
感謝您的回答。不,它不。我如何創建它? – bunnyjesse112