架构'名称'不存在德比

时间:2016-03-29 18:57:23

标签: java database jdbc schema derby

看起来我不会更进一步: 我正在尝试“以编程方式”启动虚拟服务器(在java文件中)但是当我运行项目时,我得到了一个 Schema不存在消息

public class Giocatori extends javax.swing.JFrame {

  Connection con;
  Connection conn;
  Statement stmt;
  ResultSet rs;
  int curRow=0;


    public Giocatori() {
        initComponents();
      try {
          DoConnect();
      } catch (IllegalAccessException ex) {
          Logger.getLogger(Giocatori.class.getName()).log(Level.SEVERE, null, ex);
      } catch (InstantiationException ex) {
          Logger.getLogger(Giocatori.class.getName()).log(Level.SEVERE, null, ex);
      } catch (Exception ex) {
          Logger.getLogger(Giocatori.class.getName()).log(Level.SEVERE, null, ex);
      }
    }

    public void DoConnect() throws IllegalAccessException, InstantiationException, Exception {
        try {
            NetworkServerControl serverControl = new NetworkServerControl(InetAddress.getByName("localhost"),1527);
            serverControl.start(null);

            Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();           
    DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
    String host = "jdbc:derby://localhost:1527/db";
    String uName = "username";
    String uPass= "password";
pannellosotto.setVisible(false);
//When the method getConnection is called, the DriverManager will attempt to locate a suitable driver from amongst those 
//loaded at initialization and those loaded explicitly using the same classloader as the current applet or application. 
 con = DriverManager.getConnection(host, uName, uPass);

 //Statement: Used to implement simple SQL statements with no parameters.
//PreparedStatement: (Extends Statement.) Used for precompiling SQL statements that might contain input parameters. See Using Prepared Statements for more information.
//CallableStatement: (Extends PreparedStatement.) Used to execute stored procedures that may contain both input and output parameters. See Stored Procedures for more information

 stmt = con.createStatement();
String SQL = "SELECT * From Giocatori";
/*To execute a query, call an execute method from Statement such as the following:

    execute: Returns true if the first object that the query returns is a ResultSet object. 
Use this method if the query could return one or more ResultSet objects. Retrieve the ResultSet 
objects returned from the query by repeatedly calling Statement.getResultSet.
    executeQuery: Returns one ResultSet object.
    executeUpdate: Returns an integer representing the number of rows affected by the SQL statement. 
Use this method if you are using INSERT, DELETE, or UPDATE SQL statements */
 rs = stmt.executeQuery(SQL);

 rs.next();

架构 存在。它也被设置为默认架构...

0 个答案:

没有答案