Results 1 to 11 of 11
Thread: netbeans database problem
- 12-27-2009, 11:01 PM #1
Member
- Join Date
- Dec 2009
- Posts
- 20
- Rep Power
- 0
netbeans database problem
i'm a novice in programming and i have the following problem
i'm trying to fill a combobox with strings collected from the resultset from a query.
with numbers i can get it to work but not white strings can sombody show my an example ?
i get the error table/view *** not exist
-
Why not show us your code (with code tags) and the actual error message?
- 12-28-2009, 02:11 PM #3
Member
- Join Date
- Dec 2009
- Posts
- 20
- Rep Power
- 0
here it is
db class
}Java Code:public class DATABANK { public Connection conn = null; public Statement stmt = null; public ResultSet rs = null; public DATABANK(String sql) { try { String dbURL = "jdbc:derby://localhost:1527/INFOREGISTRATIE"; Class.forName("org.apache.derby.jdbc.ClientDriver" ); conn =DriverManager.getConnection(dbURL); stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSI TIVE, ResultSet.CONCUR_UPDATABLE); rs=stmt.executeQuery(sql); //rs.close(); } catch (Exception ex) { JOptionPane.showMessageDialog(null,ex.getMessage() );
}
}
event
Java Code:private void jComboBoxmedewerkerMouseClicked(java.awt.event.Mou seEvent evt) { databankmedewerkers= new DATABANK("select * from MEDEWERKERS where MEDEWERKERNAAM= " + jComboBoxmedewerker.getSelectedItem()); try { databankmedewerkers.rs.first(); medewerker.setText(databankmedewerkers.rs.getString("medewerkernaam")); databankmedewerkers.rs.close(); } catch (SQLException ex) { } }Last edited by bikkerss; 12-30-2009 at 01:11 PM.
- 12-29-2009, 10:22 PM #4
Member
- Join Date
- Dec 2009
- Posts
- 20
- Rep Power
- 0
Nobody that sees the problem ?
-
- 12-30-2009, 01:51 PM #6
Member
- Join Date
- Dec 2009
- Posts
- 20
- Rep Power
- 0
Error code:
Syntax error: Encountered "null" at line 1 column 49
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at eindwerkinfovragen.INGAVEFORM.jComboBoxmedewerkerM ouseClicked(INGAVEFORM.java:795)
at eindwerkinfovragen.INGAVEFORM.access$100(INGAVEFOR M.java:25)
at eindwerkinfovragen.INGAVEFORM$2.mouseClicked(INGAV EFORM.java:271)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEvent Multicaster.java:253)
at java.awt.Component.processMouseEvent(Component.jav a:6266)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3267)
at java.awt.Component.processEvent(Component.java:602 8)
at java.awt.Container.processEvent(Container.java:204 1)
at java.awt.Component.dispatchEventImpl(Component.jav a:4630)
at java.awt.Container.dispatchEventImpl(Container.jav a:2099)
at java.awt.Component.dispatchEvent(Component.java:44 60)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4574)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4247)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4168)
at java.awt.Container.dispatchEventImpl(Container.jav a:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475 )
at java.awt.Component.dispatchEvent(Component.java:44 60)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
it's weird beceause i don't have 49 colums
- 12-30-2009, 01:54 PM #7
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
What is line 795 of INGAVEFORM.java?
- 12-30-2009, 02:27 PM #8
Member
- Join Date
- Dec 2009
- Posts
- 20
- Rep Power
- 0
databankmedewerkers.rs.first();
-
So either databankmedewerkers or databankmedewerkers.rs is null. You will need to find out why.
- 12-30-2009, 02:41 PM #10
Member
- Join Date
- Dec 2009
- Posts
- 20
- Rep Power
- 0
whitch would indicate the query is empty or do i miss understand ?
i have filled the database
- 01-04-2010, 09:03 AM #11
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
A resultset will not come back null* from a query. It will simply be empty (this is not the same as null).
However this - "Syntax error: Encountered "null" at line 1 column 49" - is a SQL error, implying you have a problem in your SQL statement. Since you then continue on in your code it seems you ignore this problem and assume your query has worked.
I'm guessing a bit, but I suspect it's down to you concatentiaing your query together rather than using a PreparedStatement.
* - Except for one db that eludes me at the moment, but it's not likely to be the one you're using.
Similar Threads
-
Using Derby Database in Netbeans
By DavidG24 in forum New To JavaReplies: 1Last Post: 09-14-2009, 01:29 PM -
database with mysql using the netbeans 6.0
By kwesiaryee in forum New To JavaReplies: 2Last Post: 05-02-2008, 04:27 AM -
Problem with wsimport / Netbeans
By buk110 in forum Advanced JavaReplies: 0Last Post: 03-17-2008, 07:47 PM -
netBeans problem Restated
By elizabeth in forum NetBeansReplies: 1Last Post: 08-07-2007, 08:49 PM -
Problem with display in Netbeans 5.5
By Albert in forum NetBeansReplies: 1Last Post: 07-13-2007, 03:33 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks