473,809 Members | 2,506 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Urgent Help Needed for program due on Fri. Dec. 8th in the afternoon!

2 New Member
below is my almost completed code. I need help trying to figure out how to display to a textarea all the data I have in phpMyAdmin (database). I have two methods near the bottom called itemResults() and productResults( ) with the body of them commented out so it will compile. What is commented out is the way I think it should work but it is not working. If anyone would like to see entire code I would be glad to email for it will not let me post all of it. I have it on the web if you would like to see it working and have better idea of what I need: http://web6.duc.auburn.edu/~halljab/...runapplet.html Any help would be greatly appreciated.

Expand|Select|Wrap|Line Numbers
  1.  
  2. public void loadDatabase()
  3. {
  4.  
  5. try
  6. {
  7.  
  8. //Load MySQL drivers
  9. Class.forName("org.gjt.mm.mysql.Driver");
  10.  
  11. }
  12.  
  13. catch( java.lang.ClassNotFoundException e )
  14. {
  15.  
  16. showStatus("MySQL ORG Package Driver not found ...");
  17. System.err.println(e.getMessage());
  18.  
  19. }
  20.  
  21. try
  22. {
  23.  
  24. //Connect to the database
  25. conBrads_mySQL = DriverManager.getConnection(dbURL);
  26.  
  27. }
  28.  
  29. catch(SQLException error)
  30. {
  31.  
  32. System.err.println("Unable to Connect to Database");
  33.  
  34. }
  35.  
  36. try
  37. {
  38.  
  39. Statement cmdBrads_mySQL = conBrads_mySQL.createStatement();
  40.  
  41. //Create the ResultSet
  42. rsBrads_mySQL = cmdBrads_mySQL.executeQuery("Select * from Brads_mySQL.Items;");
  43. loadItemName(rsBrads_mySQL);
  44.  
  45. rsBrads_mySQL = cmdBrads_mySQL.executeQuery("Select * from Brads_mySQL.Products;");
  46. loadProductName(rsBrads_mySQL);
  47.  
  48. blnSuccessfulOpen = true;
  49.  
  50. }
  51.  
  52. catch(SQLException error)
  53. {
  54.  
  55. System.err.println("Error in recordset");
  56.  
  57. }
  58. }
  59.  
  60. public void loadItemName(ResultSet rsBrads_mySQL)
  61. {
  62.  
  63. //Fill item list box
  64. try
  65. {
  66.  
  67. while(rsBrads_mySQL.next())
  68. {
  69.  
  70. lstItems.add(rsBrads_mySQL.getString("ItemName"));
  71.  
  72. }
  73. }
  74.  
  75. catch (SQLException error)
  76. {
  77.  
  78. System.err.println("Error in Display Record");
  79.  
  80. }
  81. }
  82.  
  83. public void loadProductName(ResultSet rsBrads_mySQL)
  84. {
  85.  
  86. //Fill product list box
  87. try
  88. {
  89.  
  90. while(rsBrads_mySQL.next())
  91. {
  92.  
  93. lstProducts.add(rsBrads_mySQL.getString("ProductName"));
  94.  
  95. }
  96. }
  97.  
  98. catch (SQLException error)
  99. {
  100.  
  101. System.err.println("Error in Display Record");
  102.  
  103. }
  104. }
  105.  
  106. public void actionPerformed (ActionEvent event)
  107. {
  108.  
  109. Object objSource = event.getSource();
  110.  
  111. if (objSource == btnAddItem && event.getActionCommand() == "Add")
  112. addItems();
  113. else if (objSource == btnAdd && event.getActionCommand() == "Add")
  114. addProducts();
  115. else if (objSource == btnAddItem)
  116. saveItems();
  117. else if(objSource == btnEditItem)
  118. editItems();
  119. else if(objSource == btnDeleteItem)
  120. deleteItems();
  121. else if(objSource == btnCancelItem)
  122. cancelItems();
  123. else if (objSource == btnAdd)
  124. saveProducts();
  125. else if(objSource == btnEdit)
  126. editProducts();
  127. else if(objSource == btnDelete)
  128. deleteProducts();
  129. else if(objSource == btnCancel)
  130. cancelProducts();
  131. else if(objSource == btnFirstItem)
  132. firstItemRecord();
  133. else if(objSource == btnPreviousItem)
  134. previousItemRecord();
  135. else if(objSource == btnNextItem)
  136. nextItemRecord();
  137. else if(objSource == btnLastItem)
  138. lastItemRecord();
  139. else if(objSource == btnFirst)
  140. firstProductRecord();
  141. else if(objSource == btnPrevious)
  142. previousProductRecord();
  143. else if(objSource == btnNext)
  144. nextProductRecord();
  145. else if(objSource == btnLast)
  146. lastProductRecord();
  147. else if(objSource == btnItemDisplay)
  148. itemResults();
  149. else if(objSource == btnProductDisplay)
  150. productResults();
  151.  
  152. }
  153.  
  154. public void itemStateChanged(ItemEvent event)
  155. {
  156.  
  157. String strItemName = lstItems.getSelectedItem();
  158. String strProductName = lstProducts.getSelectedItem();
  159.  
  160. showStatus("");
  161.  
  162. Object objSource = event.getSource();
  163.  
  164. if (objSource == lstItems)
  165. {
  166.  
  167. try
  168. {
  169.  
  170. Statement cmdBrads_mySQL = conBrads_mySQL.createStatement();
  171. rsBrads_mySQL = cmdBrads_mySQL.executeQuery(
  172. "Select * from Brads_mySQL.Items where ItemName = '" + strItemName + "';");
  173. txtItemName.setText(strItemName);
  174. displayItemRecord(rsBrads_mySQL);
  175. itemAlteredState();
  176.  
  177. }
  178.  
  179. catch(SQLException error)
  180. {
  181.  
  182. showStatus("Error in recordset");
  183.  
  184. }
  185. }
  186.  
  187. else if (objSource == lstProducts)
  188. {
  189.  
  190. try
  191. {
  192.  
  193. Statement cmdBrads_mySQL = conBrads_mySQL.createStatement();
  194. rsBrads_mySQL = cmdBrads_mySQL.executeQuery(
  195. "Select * from Brads_mySQL.Products where ProductName = '" + strProductName + "';");
  196. txtProductName.setText(strProductName);
  197. displayProductRecord(rsBrads_mySQL);
  198. productAlteredState();
  199.  
  200. }
  201.  
  202. catch(SQLException error)
  203. {
  204.  
  205. showStatus("Error in recordset");
  206.  
  207. }
  208. }
  209. }
  210.  
  211. public void displayItemRecord(ResultSet rsBrads_mySQL)
  212. {
  213.  
  214. //Display the current record
  215. try
  216. {
  217.  
  218. if(rsBrads_mySQL.next())
  219. {
  220.  
  221. txtItems.setText(rsBrads_mySQL.getString("ItemID"));
  222. txtItemName.setText(rsBrads_mySQL.getString("ItemName"));
  223. txtItemQuantity.setText(rsBrads_mySQL.getString("ItemQuantity"));
  224. txtItemDescription.setText(rsBrads_mySQL.getString("ItemDescription"));
  225. showStatus("");
  226.  
  227. }
  228.  
  229. else
  230. {
  231.  
  232. showStatus("Record not found");
  233. clearItemTextFields();
  234.  
  235. }
  236. }
  237.  
  238. catch (SQLException error)
  239. {
  240.  
  241. showStatus("Error in display record");
  242.  
  243. }
  244. }
  245.  
  246. public void displayProductRecord(ResultSet rsBrads_mySQL)
  247. {
  248.  
  249. //Display the current record
  250. try
  251. {
  252.  
  253. if(rsBrads_mySQL.next())
  254. {
  255.  
  256. txtProduct.setText(rsBrads_mySQL.getString("ProductID"));
  257. txtProductName.setText(rsBrads_mySQL.getString("ProductName"));
  258. txtProductQuantity.setText(rsBrads_mySQL.getString("ProductQuantity"));
  259. txtProductDescription.setText(rsBrads_mySQL.getString("ProductDescription"));
  260. showStatus("");
  261.  
  262. }
  263.  
  264. else
  265. {
  266.  
  267. showStatus("Record not found");
  268. clearProductTextFields();
  269.  
  270. }
  271. }
  272.  
  273. catch (SQLException error)
  274. {
  275.  
  276. showStatus("Error in display record");
  277.  
  278. }
  279. }
  280.  
  281. public void itemResults()
  282. {
  283.  
  284. //Display the Report
  285. //try
  286. //{
  287.  
  288. //if(rsBrads_mySQL.next())
  289. //{
  290.  
  291. //txaItemReport.append("" + txtItems.setText(rsBrads_mySQL.getString("ItemID"))
  292. //+ "\n" + txtItemName.setText(rsBrads_mySQL.getString("ItemName")) + "\n" +
  293. //txtItemQuantity.setText(rsBrads_mySQL.getString("ItemQuantity")) + "\n" +
  294. //txtItemDescription.setText(rsBrads_mySQL.getString("ItemDescription")) + "\n\n\n");
  295. //showStatus("Report Complete");
  296.  
  297. //}
  298.  
  299. //else
  300. //{
  301.  
  302. //showStatus("Record not found");
  303.  
  304. //}
  305. //}
  306.  
  307. //catch (SQLException error)
  308. //{
  309.  
  310. //showStatus("Error trying to Report");
  311.  
  312. //}
  313. }
  314.  
  315. public void productResults()
  316. {
  317.  
  318. //Display the Report
  319. //try
  320. //{
  321.  
  322. //if(rsBrads_mySQL.next())
  323. //{
  324.  
  325. //txaProductReport.append("" + txtProduct.setText(rsBrads_mySQL.getString("ItemID"))
  326. //+ "\t" + txtProductName.setText(rsBrads_mySQL.getString("ItemName")) + "\t" +
  327. //txtProductQuantity.setText(rsBrads_mySQL.getString("ItemQuantity")) + "\t" +
  328. //txtProductDescription.setText(rsBrads_mySQL.getString("ItemDescription")) + "\n\n");
  329. //showStatus("Report Complete");
  330.  
  331. //}
  332.  
  333. //else
  334. //{
  335.  
  336. //showStatus("Record not found");
  337.  
  338. //}
  339. //}
  340.  
  341. //catch (SQLException error)
  342. //{
  343.  
  344. //showStatus("Error trying to Report");
  345.  
  346. //}
  347. }
  348.  
Dec 6 '06 #1
3 1380
Niheel
2,456 Recognized Expert Moderator Top Contributor
Using the CODE tags would have been nice.
Made the changes for you.
Dec 7 '06 #2
r035198x
13,262 MVP
Using the CODE tags would have been nice.
Made the changes for you.
We do not have your database so testing this might be a bit difficult. So why don't you specify what errors you are getting when compiling.
Dec 7 '06 #3
coopst1
2 New Member
Coded as it is now with the itemReport() commented out it compiles because the method is not used but the following is the error I am getting if I uncomment it (same with productReport() ):

Expand|Select|Wrap|Line Numbers
  1. "Inventory.java": 'void' type not allowed here at line 1030, column 30
  2. "Inventory.java": 'void' type not allowed here at line 1031, column 9
  3. "Inventory.java": 'void' type not allowed here at line 1031, column 75
  4. "Inventory.java": 'void' type not allowed here at line 1032, column 74
Dec 7 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5011
by: Ramki | last post by:
Hi, I want to call a PERL program from MS-DOS batch file. Following is just an example, the string may inturn have double quote or single quote. I can't call with arg1, arg2 etc, as the input will be dyanamic. My argument may be something like this "204.120.69.195" "-""-" 'xyz' "GET" Perl should receive the whole string as a single argument. I know it
7
4073
by: meenasamy | last post by:
Hi all, i need to create a function that takes three parameters( Original currency, needed currency, amount) i need to convert from the original currency to the needed currency the amount and return the new amount in the needed currency, I need this function to work real time (obtaining real time currency exchange rates), any ideas???
3
6482
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the packet has the urgent flag set, the text read from the socket is missing the last character (line feed). When the same text is sent without the urgent flag set, all of the characters are read. I'm reading the data using the blocking read call of the network stream class. The .NET...
1
2187
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include <string>
1
1605
by: alfie27 | last post by:
Hi, Here is what the final output to the screen should look like. Below this is the code I have so far. Can someone please help me as to what i need to do next?? I'm really clueless right now. Thanks! Point of Sale Terminal ----------------- 1. Record a Transaction 2. Transaction History
1
3209
by: nela | last post by:
Hello everyone, from Croatia ! I am designing a site for a Serbian client, and the english page is ok, but the serbian page needs to be cyrillic. It was no problem for Photoshop design, but I inserted a little greeting in java (found free online), good morning, good afternoon... This is part of the code: hours = today.getHours(); if (hours<12) greeting = 'Good morning!'; if (hours<18 && hours>11) greeting = 'Good afternoon!';
1
1167
by: irfi | last post by:
Ok can anyone help me with this problem I have to create a program in NetBeans 4.0 and this is the requirement:- I have to create a base class which consists of EMPLOYEE NAME, CODE and DESIGNATION. The derived class contains the data members YEARS OF EXPERIENCE and AGE. The values have to be stored in the array. FOLLOWING ACTION HAS TO BE DONE WHEN PROGRAM RUNS. 1. User can view the values stored in the arrays 2. User can enter a new entry...
2
1804
by: =?ISO-8859-1?B?RulybmFz?= | last post by:
Hey all, I have a URGENT problem and I hope someone could help me... scenery: I have a windows app, coded using C# (framework 1.1 - VS2003)... The exe and dlls of the app is are stored in a server, and the clients access this app through a shortcut that points to this. The folder of
2
1827
by: thecheyenne | last post by:
Hi and good evening / good morning (depending on your location on this planet) Despite my limited - o.k, non-existing - knowledge of vba, I'd like to design a database to help with the admin of school outings. I pretty much know my way around MS access, but may well need vba for this thing here, so if you have any hints and tips for me, I'd be most grateful. The outline of the day-out is as follows: There is a pool of activities...
0
9722
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10643
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10378
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10121
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.