简体   繁体   English

netbeans Java数据库应用程序

[英]netbeans java database application

The setup of my app: 我的应用程序的设置:

设定

and the error that is thrown: 和引发的错误:

错误

Hello, I am pretty new to java and netbeans. 您好,我对Java和Netbeans很陌生。 I previously worked on Adobe Flash. 我以前使用过Adobe Flash。 I am having this problem where error of db or table not found is being thrown. 我在抛出未找到数据库或表的错误的地方遇到了这个问题。 If anybody could makeout anything from the screenshots attached, Please help me. 如果有人可以从随附的屏幕截图中识别出任何内容,请帮助我。 I am trying to use the derby.jdbc.EmbeddedDriver here to store data. 我试图在这里使用derby.jdbc.EmbeddedDriver来存储数据。

Below is the entire code. 以下是整个代码。

  package loginapp;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.ResultSetMetaData;
  import java.sql.Statement;

 public class Loginapp {

 public static void main(String[] args) {
    // TODO code application logic here
    try
    {
        chkLogin();
    }
    catch(Exception e){
       e.printStackTrace(); 
    }
}
private static void chkLogin() throws Exception{
    Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
    Connection conn = DriverManager.getConnection("jdbc:derby:testdb;create=true");
    Statement stmnt = conn.createStatement();
    ResultSet results = stmnt.executeQuery("select * from USERLOGIN");
    ResultSetMetaData rsmd = results.getMetaData();
    int numCols = rsmd.getColumnCount();
    for(int i=0;i<=numCols;i++)System.out.print(rsmd.getColumnLabel(i)+"\t\t");
}   
}

Have included derby.jar in my library and the "jdbc:derby:testdb;create=true [user1 on APP]" points to the db. 在我的库中包含了derby.jar,并且“ jdbc:derby:testdb; create = true [APP上的user1]”指向数据库。 Am able to update when I do it from the SQL window. 从SQL窗口执行更新时能够更新。

Thank you 谢谢

As explained here , 正如解释在这里

Three common reasons for "table does not exist" when you think you've already created the tables: 当您认为已经创建表时,“表不存在”的三个常见原因:

  1. You are connecting to a different database than you think you were connecting to, and since you specified "create=true" on the Connection URL, Derby quietly created a new empty database for you. 您正在连接的数据库与您认为要连接的数据库不同,并且由于在“连接URL”上指定了“ create = true”,因此Derby悄悄地为您创建了一个新的空数据库。
  2. You are using the "in-memory" configuration of Derby, which means that when the database is closed (or your application exits), all the contents of the database disappear. 您正在使用Derby的“内存中”配置,这意味着当数据库关闭(或应用程序退出)时,数据库的所有内容都会消失。
  3. You are connecting to the database as a different user, and you aren't issuing the SET SCHEMA statement, so you are using the default schema name, which is based on your user name, and so the two schemas are different and have completely different tables, so the table you created doesn't seem to exist when you use the other schema. 您将以不同的用户身份连接到数据库,并且没有发出SET SCHEMA语句,因此您使用的是基于您的用户名的默认架构名称,因此这两个架构是不同的,并且完全不同表格,因此当您使用其他架构时,您创建的表格似乎不存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 MySQL Workbench 数据库连接到 NetBeans 中的 Java 应用程序 - Connecting MySQL Workbench database to a Java application in NetBeans NetBeans Java应用程序-在derby数据库上执行查询 - Netbeans java application - executing query on derby database 如何在NetBeans中更改Java数据库应用程序的标题 - How to change title of java database application in netbeans Netbeans Java应用程序-在MySql数据库上执行查询 - Netbeans java application - executing query on MySql database 使用Java持久性在Netbeans中通过数据操作创建数据库桌面应用程序 - Creating database desktop application with data manipulation in Netbeans using Java Persistence 我想将 Netbeans java 应用程序与 Firebase 数据库连接 - I want to connect a Netbeans java application with Firebase Database Java应用程序-如何显示NetBeans中mysql数据库中的所有记录? - Java application - How to display all the records from mysql database in netbeans? Netbeans 7.2.1。 嵌入式Derby数据库的Java应用程序 - Netbeans 7.2.1. Java Application with Embedded Derby Database 在NetBeans中使用可更新的derby数据库将Java应用程序打包为exe安装程序 - Packaging a java application as exe installer with an updatable derby database in netbeans Netbeans Java桌面数据库应用程序,具有从mysql连接到用户的登录名 - Netbeans Java Desktop Database application with login connecting to users from mysql
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM