开发者

JTable binding using netbeans GUI builder

I have used netbeans GUI builder to bind a JTable to a simple mysql db called Products having a table called products. So a class with name "Products" was generated and I guess It's a bean (Am I right?If so ..then Why it was generated as a bean?) . I am reading 开发者_StackOverflow社区the generated code for the purpose of learning and I found out that the Jtable is bound with a list coming from mysql result array

products_dbPUEntityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("products_dbPU").createEntityManager();
productsQuery = java.beans.Beans.isDesignTime() ? null : products_dbPUEntityManager.createQuery("SELECT p FROM Products p");

I looked at createEntityManager and createQuery and they are both empty and I can't find where are they overridden . Where's the MYSQL connection code ? I have looked everywhere for something like that

 Class.forName("com.mysql.jdbc.Driver");
 String connectionUrl = "jdbc:mysql://localhost/mysql?" +
                                   "user=root&password=123456";
 Connection con = DriverManager.getConnection(connectionUrl);
 System.out.println("Connection Ok!");
 Statement stmt = null;
 ResultSet rs = null;
 //SQL query command
 String SQL = "SELECT * FROM products_db.products";
 stmt = con.createStatement();
 rs = stmt.executeQuery(SQL);

but I can't find it . What's missing ?


It looks Like you're using JPA.

which means that all of your db settings will be in a file called persistence.xml

products_dbPUEntityManager.createQuery("SELECT p FROM Products p");

This is actually the JPQL (SQL for JPA) statement that translates to

String SQL = "SELECT * FROM products_db.products";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜