Retrieving Data From Database Based On User Input

Jan 18, 2015

I need to take the users input from 2 boxes and reference that to a sqlite database and populate the fields with the data in the database. I know the database code work.

Here is the code for the "user" form;

Java Code:

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTextField;
import java.awt.Font;

[Code] .....

View Replies


ADVERTISEMENT

Retrieving Result By User Input Different Combination Using String Tokenizer (MYSQL)

Mar 30, 2014

I am creating a simple Symptom Checker application. The problem I have is that I'm trying to retrieve user input (JTextField) by comma's using StringTokenizer which contacts the database for a result which matches the user's input (SELECT * FROM DIAGNOSIS WHERE ?, ?, ?) . It successfully finds the correct result however only in a particular format. Not different combinations....

for example, if I enter say within the JTextField: "tearful, nausea, lack of motivation" it will find the result successfully (as that is how it is formatted within the particular column (in the database table) i wish to display a result from) however, if i enter a different combination of these symptoms: "nausea, lack of motivation, tearful" - it will not find any result. I'm very unsure how to make it work regardless of what is inputted first, second or last.

Here is the code:

public void actionPerformed(ActionEvent e) {
try {
String abc = fieldsymp1.getText();
StringTokenizer str = new StringTokenizer(abc);
while (str.hasMoreTokens()) {
str.nextToken((", ")).trim();
 
[Code] ....

View Replies View Related

Retrieving User Input String From Keyboard - Program Errors (try / Catch)

Sep 23, 2014

I need to design, implement, and test a program to input and analyze a name. The program begins by retrieving a user input string from the keyboard. This string is intended to be the user's name. These are the errors we have to search analyze the user input for: No blanks between names firstName and lastName, Non-alphabetic characters in names, Less than two characters in first name, and Less than two characters in last name. Each of these errors must be thrown. All exceptions must be derived from a programmer-defined class called NameException. Each exception should use a detailed message to differentiate among the file types of errors.

This is the format of my NameException class, is the format itself correct? I will fill in the details of each exception I am just wondering if that is how I should set it up.

public class NameException extends Exception {
private String firstName, lastName;
public NoBlanksException(String firstName,String lastName) {
}
public NonAlphabeticalCharactersException(String firstName, String lastName) {

[Code] .....

I was told not to try and catch thrown errors in the main method, would I just create another method in the Driver class to take care of that then?

View Replies View Related

Printing Unfilled Diamond Based On User Input

Jan 31, 2015

I am new to learning Java and I am trying to print an unfilled diamond using asterisks. The height of the diamond has to be based on user input. My code currently prints out a filled diamond based on user input but I cannot figure out how to print an unfilled one. Every time I change one of the loops it messes something else up.

[public static void diamond(){
int i = 0;
int j = 0;
int k = 0;
int height = 0;

[code]...

View Replies View Related

GUI To Display Search Results Based On User Input Server Name

Jul 18, 2014

I am using a GUI to display search results based on user's input server name. I am using MS Access as DB and I have the DSN set up correctly.But the search results are displayed for the first typed value in text filed. I am getting same result set every time though i input different server names .

import java.sql.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.DefaultTableModel;
public class SearchResult implements ActionListener{

[Code]...

View Replies View Related

Swing/AWT/SWT :: Taking Inputs Based On Previous User Input

Jun 7, 2014

I'm developing a Swing application for the first time. To test my application, I have currently hardcoded some text labels and fields in a JPanel, so that a user can enter input details for a maximum of 3 segments. But this limits the maximum number of segments to 3. However, the requirement is that when the user enters the number of segments (could be greater than 3 as well), corresponding number of input sets need to be taken.

Screenshot attached, with values entered.

Basically I want to know how I should go about taking the inputs from the user.

View Replies View Related

Servlets :: Generate M By N Multiplication Table Based On User Input

May 8, 2014

I have a basic html form with one user input text box labeled "Enter a number" and a submit button labeled "Create a multiplication table". This is the working with a servlet to display an html formatted multiplication table. Everything else is working fine just the formatting is off; I can't seem to get the top row and far left column to number properly. It should look like this with the top row of numbers beginning with a blank cell and then numbering 1 thru n (depending on what the user selects. The first column should be the same, a blank cell and then 1 thru n. Then the multiplication table should be in the rows/columns of the table. Picture this:

I can't get mine to start with a blank cell in the top left-hand corner, instead it has 1 in that cell and the table starts calculating with 2x2.

Servlet code:

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

[Code] ....

View Replies View Related

Boolean Method - Adding Information To Mailing List Based On User Input

May 5, 2014

This program contains a superclass and a subclass that will gather the following information from the user:

name, address, phone number, and customer number.

Everything works fine except that I have to create a boolean method in this program that is required to determine based on user input whether they want to be added to a mailing list.

I cannot get this method to work with main, each time it is called it will always return the value but main will constantly read the last statement (else, where it will read "not wanting to be added to the mailing list).

The only way I can get this part of the program to work is by adding an equals method in main that ignores the case, but I am required to write a boolean method so this is not allowed.

Superclass:

public class Person
{
private String name;
private String address;
private String phoneNum;
public Person(String pName, String add, String number)
{
name = pName;
address = add;

[Code] ...

View Replies View Related

User Input All Of Data On A Single Line And Implement StringTokenizer To Assign That Data To File

Mar 21, 2015

By using FileReader, FileWriter and their constituents, I am creating a file to contain employee information ( name, age, hours, etc. ). The user is to input all of the data on a single line and we were asked to implement StringTokenizer to assign that data to the file. I have never used the StringTokenizer before, but I have a rough idea how it is to function. I used pw.println to test what I have so far, now I would like to let the user build the initial file with the "first employees" of the company, and then view the file, and then go back and append new employee data to that same file. My question is, how can I take the user input as a StringTokenizer and add that to the file?

In the for loop below, I thought I would see if it would work, but it does not. The loop only executes once and does not allow me to enter data.

public class Records {
public static void main(String [] args) throws IOException {
Scanner input = new Scanner(System.in);
FileWriter fw = new FileWriter("dbs3.java");
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter pw = new PrintWriter(bw);
System.out.println("NEW EMPLOYEE DATA SHEET");
System.out.print("Number of new employees: ");
int number = input.nextInt();

[Code] ....

View Replies View Related

GUI Confirm Button - Saving Data Input Into Database

May 4, 2014

We are currently trying to use the "confirm" button on our GUI as a fully functioning feature that saves the data input into a database. Here is the code for the GUI we have created...

We are trying to save some details of users for a database.

I've attached our work in zipped folder as i couldn't upload a thread with some many "URLs" .....

View Replies View Related

Edit User Information By Bringing In Input Fields From Database Using JSP

Jul 11, 2014

I can insert data in database, delete aslo using JSP. But facing problem while updating the information saved in database as m using MySQL 2008. I want to see the bring saved in database with particular username into the updateinfo.jsp form.

View Replies View Related

Checking If Matrix Is Upper Or Lower Triangular Matrix Based On User Input

Dec 5, 2014

java program that will determine if the matrix is a lower or upper triangular matrix. I only need to use java.util.Scanner;.

View Replies View Related

JSF :: Retrieving Hidden Input

Jun 23, 2014

I have this code

<h:form id="theform">
<h:inputHidden id="user_id" value="3" />
<h:commandButton action="userprofile.xhtml?faces-redirect=true" value="Profile" />
</h:form>

How I can retrieve the value of user_id at page userprofile.xhtml?

View Replies View Related

Retrieving Data From DB And Setting Into Textfield

Jul 10, 2014

How to do this <not in sql> .

View Replies View Related

How To Delimit Spaces In User Input Separating Two Data Types

Jan 17, 2015

I am creating a calculator in which a user will directly input the numbers and the operator...

Here is my code:

int answer = 0;
int num1, num2;
char operator;
System.out.print("Enter calculation: ");
num1 = kb.nextInt();
operator = kb.next().charAt(0);
num2 = kb.nextInt();

The code above will accept the user input when there are spaces like this: 1 + 1

So the program will give an answer which is 2...BUT

if i input 1+1 it will give an error...Exception in thread "main" java.util.InputMismatchException

How can i do that it will separate integer to character? because i set the operator as character....

So that it will accept one digit to several digit numbers... like 500+84 or 1520+872??

View Replies View Related

Swing/AWT/SWT :: Null Pointer Exception When Retrieving Data From Table

Mar 31, 2015

I am trying to export data from a jtable to a pdf report but every time i try running the code it gives me this exception:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at GUI.QC_receiving_book.printButtonActionPerformed(QC_receiving_book.java:309)
at GUI.QC_receiving_book.access$600(QC_receiving_book.java:26)
at GUI.QC_receiving_book$7.actionPerformed(QC_receiving_book.java:165)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)

[Code] ....

I tried avoiding the null exception by using the if statement but it didn't work. The row I choose from the table is full meaning there are no empty attributes. and all the data are imported from a mysql database to the table as String so there can't be any casting errors.

This is the part of the source code with the problem and i will also post the printing method. I tried debugging the class and when stepping into the first if statement it opened the jTable.java file and pointed at the getSelectedRow() method and this sentence "variable information not available.source compiled without -g option"

private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {
if(samplesTable.getSelectedRow() >= 0){
int row = samplesTable.getSelectedRow();
System.out.println(row);
for(int x=0;x<samplesTable.getColumnCount();x++){
String value = samplesTable.getModel().getValueAt(row, x).toString();

[Code] ....

View Replies View Related

User Input Data As String And If Verified As Valid Number Then Convert Into Double

Nov 11, 2014

I am writing a code in which a user inputs data as a string and that data must be verified as a valid number. A valid number is anything from 0-100. Then all valid numbers are converted into double numbers.

I am having trouble in how to write the validation part of the code.

Is it suppose to be an if, else statement? And if so how is it suppose to be validated?

View Replies View Related

Using GUI Based Program To Communicate With Database

Apr 24, 2015

In a project we are using a gui based program to communicate with a database. My issue is the formatting within the GUI.

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.*;

[code]...

This is what the gui looks like at run time. The question is how do I compact it so there is not so much space between the labels and the textArea. I've tried using different numbers on my GridLayout, but not a lot of success.

View Replies View Related

Enable Radio Button Based On Value Selected From Database

Dec 2, 2014

Enable Radio Button Based On The Value Selected From Database ????

View Replies View Related

Text Based RPG - Allow User To Change Their Name

Sep 26, 2014

String name = "Aaron";
String whatToChange = "name";
String verifyNameChange = "";
boolean changeName = false;

if(whatToChange.equals("name")){
while(!changeName){

[Code] ....

I've been working on a small text-based RPG for fun. This particular part is supposed to allow the user to change their name. Now, the problem is that when they reach the option to change their name, the above code seems to skip the line:

name = scan.nextLine();

It will erase whatever the player previously entered for their name, as well. So it will print out:

Okay, let's change your name. What did you say it was? Alright, so you'll go by . Is that correct? [now allows input for verifyNameChange]

The above code works fine on it's own, but somehow messes up when put into the full program. I don't want to post the whole program, because it's fairly large. But the String name is set and functions fine before this bit of code.

View Replies View Related

Age Calculation Based On Input (Date Of Birth)

Nov 9, 2014

I am trying to solve this problem but it is not working properly, when i enter the date of birth, such as 1993 12 14 it comes up as 21 years old instead of 20.

import java.util.*;
class Age
{
public static void main( String [] args)
{
Calendar rightNow = Calendar.getInstance();
 
[Code] ....

View Replies View Related

Parallel Array Recall - Return Value Based On Input

Mar 8, 2015

I am having an issue with a parallel array that I created that returns array values based on an input. The code only works for the first four array locations just fine. The remaining values are not found. I thought it might be a memory allocation issue with the array size, I tried to dimension the array, however, using the Eclipse editor get errors.
 
import java.util.*;
import javax.swing.JOptionPane;
public class StudentIDArray {
static String[] studentNum = new String[]
{"1234", "2345", "3456", "4567", "5678", "6789", "7890", "8901", "9012", "0123"};
static String[] studentName = new String[]

[Code] .....

View Replies View Related

Java Program That Will Ask A User To Input Grades Until User Inputs Sentinel Value

Apr 9, 2014

Write a java program that will ask a user to input grades until the user inputs the sentinel value -1. The program should test each input to determine whether 0<=grade<=100. If the grade entered is within this range, the program should print "Grade accepted;" if not, the program should print "Invalid input".

View Replies View Related

Program That Takes User Odd Number And Print Prime Numbers Lower Than User Input

Nov 4, 2014

I have been struggling with this program for weeks. This program is supposed to take a user's inputted odd number and then print out all prime numbers lower than that number.

public class PrimeNumber
{
Scanner scan = new Scanner(System.in);
int userNum;
String neg;

public void getUserNum()

[code]...

View Replies View Related

How To Get Data Button To Display User Inputted (numbers) To Data Label

May 25, 2014

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DisplayFinal_Panel extends JPanel {
private JLabel label1, label2, label3;
private JTextField box;

[code]....

I only want Listener 1 to work right now. Also, user input is in TextField.

View Replies View Related

How To Get Index Of Array Based On User Inputted Account Number

Sep 25, 2014

In my account driver I am trying to get the user inputted account number to get the account by account number. In my code

System.out.println("Which Account number: "); int account = scan.nextInt();
ac.get(account-1);

This works if my accounts are numbered incrementally starting with one, I want it to match the inputted account number

System.out.println("Account number: "); int num = scan.nextInt();

I am thinking a for loop is probably needed. Here is my code:

public class AccountDriver {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
ArrayList<Account> ac = new ArrayList<>();
boolean more=true;
boolean again=false;

[code]....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved