My output of my app its outputting the correct data just no the format ...
code :
DatabaseQuery.java :
import java.io.*;
import java.sql.*;
import java.util.*;
public class DatabaseQuery
[Code] ....
Current output:
Stock holdings by User
User ID User Name
Stock - Description
-------------------------------------------
admin01
Default Admin
DELL Dell Computer Corp
admin01
Default Admin
MSFT Microsoft Computer Corp
[Code] ....
Desired Output :
Stock holdings by User
User ID User Name
Stock - Description
-------------------------------------------
admin01 Default Admin
DELL Dell Computer Corp
MSFT Microsoft Computer Corp
ORCL Oracle Corp
I have done 90% of the coding however i am stuck with producing the output, i just cant get the user fields to show.
I have attached a picture of the output that is required. The program consists of two classes i have attached the database class, and have inserted my coding below.
import java.sql.*; import java.io.*; import java.util.*; public class QueryDB { private Connection con = null; String userID,
I have to get my output to show as per the image attached i am very close but not there yet. I have also attached the database where i extract my information from
/* Program Name: QueryDBDB.java Purpose: to build an initial database for the stocktrakcer application */
import java.sql.*; import java.io.*; import java.util.*; public class QueryDB { private Connection con = null; String userID,firstName,lastName,name,symbol; public QueryDB() throws Exception
I have a Stock Database query class, it compiles and runs well. Thing is when i enter a user, it shows a user stock information but it repeats showing the same user in the command prompt. the repetition is so fast, you can't see the information. All i wanted was the application to show a user's info, then asks you to enter another user again and so forth. Here is the code
import java.io.*; import java.sql.*; import java.util.*; public class StockDatabaseQuery { public static void main(String[] args)throws Exception { String userID; String firstName;
I have code which query value from database, the use case is the user can enter value as 1,01,11 in database but when the user enter value in xml file he can only enter 11,01,12 in database there is two columns lets say column test1=1 and test2=2 combination of this is 12, which is the value the use will enter in xml, but sometime the use can enter test1=04 than column test2=00 how can i approach this
I got table called card with column crdind,crdpos1,cardpos2 as primary key. The user can enter value as
The rule say if you enter one number in crdpos1 eg 2 than you must enter value in crdpos2 it can be any number 1-9 but if you enter 00-09 in crdpos1 than crdpos2 is 00
The challenge I have is to query this value after they been enter. I have xml file which got field crdpos the use enter 15 which is the combination of column crdpos1=1 and crdpos2=5 ... How can I split the value crdpos and got and able to query in database in two separate column ....
I am working on a personal project and want to create a text editor to write my code. I am wondering how could I read the last input from the user and if say it was an open curly brace {, then like netbean's my editor will supply the closing curly brace. My java experience is limited but I have tried to read key board input and a few other options that did not work.
My query retrieves more than 5000 records from Oracle database. I want to display the records 100 per page. I know it is called pagination. Any detailed styp-by-guide or tutorial or example available?
I am having a problem with a PreparedStatement for a MySQL query, where the query seems to get cut off. I can't really post a self contained example, because it involves an SQL database.The part of the code with the problem...
Java Code:
public void insertEntry( Hashtable<String, String> strings, Hashtable<String, Integer> integers, Date created, Date paid, boolean enabled) throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver");
[code]....
The output of the whole program, though all it has done so far is create some default values and attempt to insert them with the above code, where the problem occurs.
Debug: SQLpaid = 1990-03-21
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorEx ception: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT enabled=0, username='default_username', created='2000-03-21', paid='1990-' at line 1 at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:45)
I'm making a small database GUI program in Java where the user is able to choose 1 out of 4 options they would want to know. i.e. They click the "League of Legends Items" button and will be prompted with an option pane for input. The files containing these items are already constructed but when input is entered into the option dialog box no output is received. I figured I would need some sort of while loop that gets a line from the text file and checks up to a substring in order to make sure it is the same as the input and then outputs what the user requested. I figured it would also have to be the same for the options except with pictures and other text to follow through. For example, the user clicks the "Champions"button where it runs through the file of champions till it finds the one requested and then displays the associated picture with it. As of now, no button displays an output after user enters an input
import java.awt.event.*; import java.awt.*; import javax.swing.*; import java.io.*; import java.io.IOException; import java.util.Scanner; public class LoLDatabase extends JFrame implements ActionListener{
I have written java program which can extract online data from url and i want to store it in data base in new token row in table so than i can use in my application . how could it be done using type4 drive ..
These are my code ...
import javax.swing.text.html.parser.*; import javax.swing.text.html.*; import javax.swing.text.*; import java.io.*; import java.util.StringTokenizer; import java.net.*; public class ParseTest extends HTMLEditorKit.ParserCallback {
Write a method named diceSum that prompts the user for a desired sum, then repeatedly rolls two six-sided dice until their sum is the desired sum. Here is the expected dialogue with the user:
Desired dice sum: 9 4 and 3 = 7 3 and 5 = 8 5 and 6 = 11 5 and 6 = 11 1 and 5 = 6 6 and 3 = 9
This is my code:
import java.util.Scanner; import java.util.Random; public class mod { public static void main(String[] args) { diceSum();
[Code] .....
it works for numbers 2 - 4, but any number from 5 - 12 just prints one output, which is not the correct desired sum.
This was my initial question: I am confused as to why this won't return the desired value. I keep running into an infinite loop or data is returned that I searched.
I still need to work on whether a user enters a search that doesn't exist......that is where I am stuck....
code has been updated......
int low = 0; int high = subArray.length; while (low < high) { System.out.println("You have entered the while loop"); int mid = (low + high) / 2;
Currently, my program converts Long values to String. And when I test it out, it do print out the correct output. However, when the converted String value is passed over to be written in a text file, it seems that BufferedWriter isn't printing out the outcome that it's supposed to be.
saltVs = Long.toString(saltV); System.out.print(saltVs); //will print out 79723172
Now the problem is here...It only prints out the last digit of the String value (instead of 79723172).
Here is my FileWriter/BufferedWriter part.
Why is that when I run my program using command prompt, it prints out the output that I wanted, but however when it comes to writing to the file, it doesn't come out right.
-In your main, you should create a thermostat and thoroughly test it. Be sure to showcase time passing and the temperature reaching the desired setting. Also, showcase switching modes from heating to cooling.
My question is, once it reaches the desired temp, would the thermostat turn off, and then how do you show switching from heating and cooling.
This is what prints.
Thermostat is: true Thermostat is: false The desired temp: 70.0 The current temp: 69.0 Tue Feb 25 19:06:21 CST 2014 Tue Feb 25 20:06:21 CST 2014 Thermostat is: true Thermostat is: false The desired temp: 70.0 The current temp: 70.0
Here is my Class:
import java.util.Random; import java.util.Date; public class Thermostat { private double currentTemp; private double desiredTemp; private double heatingThreshold; private double coolingThreshold;
i am doing a code using JSTL to fire a query. everything come fine except the resule is not sorted as desired. i am putting the code below--
String sort_order=(String)request.getAttribute("sort_order"); request.setAttribute("sort_order",sort_order); <sql:query var="viewQueryj" sql= "select USER_ID, PERMISSION_ID, USER_NAME from administrator order by ?"> <sql:param value="${sort_order}"/> </sql:query>
now the resule is always sorted by USER_ID. if i want to sort it using USER_NAME i pass parameter from controller to this page in sort_oredr variable which comes fine but the result doesn't sort by name, only by id. if i hardcode USER_NAME in query then the result is as desired.
i found some problem for this jsp code. Actually I'm new in jsp. I'm trying to insert some data in a sql table in jsp by user input. Here's my code but i couldn't completed it.
I seem to be having a issue with my java console app what it should do is query a SQL DB and list the user details (userid, firstname ,lastname) from the user table, and the users stocks (stockname ,stockdiscription) associated to each user from the userstocks table if I'm thinking correctly!
I'm sure it is just a logical error, but I'm not sure of the way to get the out put I'm looking for. I will add the makeDB.java file and DatabaseQuery.java file as well as the current Exception(Run Time Exception) below.
**I have added other users and stocks manually - Not just what the MakeDB.java file inserts **
Output and Exception:
Stock holdings by User User ID User Name Stock - Description ------------------------------------------- admin01 Default Admin Exception in thread "main" java.sql.SQLException: ResultSet is closed at sun.jdbc.odbc.JdbcOdbcResultSet.checkOpen(JdbcOdbcResultSet.java:6647 ) at sun.jdbc.odbc.JdbcOdbcResultSet.next(JdbcOdbcResultSet.java:1248) at DatabaseQuery.main(DatabaseQuery.java:45) Press any key to continue . . .
Java Code:
MakeDB.java: import java.sql.*; import java.io.*; public class MakeDB { public static void main(String[]args) throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
My console SQL Query app is not giving me the desired output.I am sure its might have something to do with my SQL Query.Its missing the description of the stock items and it prints a new line for each user as per number of stocks an repeats the user details and then prints the stock listed by that user(only want the user listed once with all its stocks). I will add my files and current output and desired out put below.
MakeDB.java:
import java.sql.*; import java.io.*; public class MakeDB { public static void main(String[]args) throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url="jdbc:odbc:StockTracker";