Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Learning Aids/Tools 2 years ago
Posted on 16 Aug 2022, this text provides information on Learning Aids/Tools related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I am using a simple app to aid learning database with Apache.Derby and working in Eclipse. The following code runs ok but conn.getMetaData() does not return anything meaningful regarding the table - colnameslist.size for example is 0. However I added meta.getDatabaseProductName() to see what happened and that returns 'Apache.Derby' so I guess there is some sort of connection.
The connection url is "jdbc:derby:C:/Users/RonLaptop/MyDB". The string passed into getTableContents() is "MYENERGYAPP.ENERGYTABLE7".
As it does not error I am at a bit of a loss.
package com.energy; import javax.swing.*; import javax.swing.table.*; import java.sql.*; import java.util.*; /** an immutable table model built from getting metadata about a table in a jdbc database */ public class JDBCTableModel extends AbstractTableModel { Object[][] contents; String[] columnNames; Class[] columnClasses; public JDBCTableModel (Connection conn, String string) throws SQLException { super(); getTableContents (conn, string); } protected void getTableContents (Connection conn, String string) throws SQLException { // get metadata: what columns exist and what // types (classes) are they? DatabaseMetaData meta = conn.getMetaData(); String productName = meta.getDatabaseProductName(); String[] types = null; System.out.println ("got meta = " + meta); ResultSet results = meta.getColumns (null, null, string, null) ; System.out.println ("got column results"); ArrayList colNamesList = new ArrayList(); ArrayList colClassesList = new ArrayList(); while (results.next()) { colNamesList.add (results.getString ("COLUMN_NAME")); System.out.println ("name: " + results.getString ("COLUMN_NAME")); int dbType = results.getInt ("DATA_TYPE"); switch (dbType) { case Types.INTEGER: colClassesList.add (Integer.class); break; case Types.FLOAT: colClassesList. REPLY 0 views 0 likes 0 shares Facebook Twitter Linked In WhatsApp
Try using just the name of the table; when I do this, I don't need to put the name of the 'app' level in front of the table name (i.e. just EVERYGYTABLE7). And make sure the table name has that capitalization; it is possible to create a table with a mixed-case name, and I think Derby is strict about that.
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.