The assignment is to create a program that accepts entries from a user for 3 variables then saves the data to a file. There are other programs that use the file created. One program displays the non-default records. The next program allows the user to enter the id for the employee and displays the first and last name for that id number. The last program allows the user to enter a first name. It then displays all id numbers and last names for records with that first name.
Given the above situation, I am stuck on creating the first program. I can make the text file and write the information to it. However, when the file is created, a space is placed in between each entry for some reason. I cannot figure out how to get rid of this space so that I can display the appropriate records for the remaining programs. Below is the code and a view of my problem.
import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.file.*; import java.io.*; import static java.nio.file.StandardOpenOption.*; import java.util.*; public class WriteEmployeeList {
[Code] .....
The values for nameFormat and lnameFormat are 10 spaces. This is how the book told me to make sure everything is uniform and searchable. The file contents look like this when viewed in notepad.
I'm starting to use AbstractTableModel to customize a JTable model. The problem appears when you add a record from a ResultSet to JTable object.
I've managed to insert records, but empty, I need that for every column I can see the data is there.
Leave some code I have been writing ... the method to insert records in JTable is called "insertEmptyRow" (for now).
I need some opinion that can make changes to the code of this method so you can get to see all the data in a record.
MyFirstModel:
public class TablaModeloPrincipal extends private String algo; private int numRegTabla; //Agrego las columnas que quier tener en el model private String[] columnNames = {"DNI", "Nombre", "Edad", "Dirección", "Empresa", "Contacto"}; Vector<String[]> clientes = new Vector<String[]>() ; public ResultSet buscarResultset() throws SQLException{ ResultSet rs=null;
So I am calling this method several times and trying to write multiple records to a file. Problem is that every time I call the method it overwrites the file from before and doesn't add it.
public void fileWriterMethod() throws IOException{ RandomAccessFile raf = new RandomAccessFile(filename, "rw"); raf.writeInt(id); raf.writeInt(existingMileage); raf.writeInt(gasCost); raf.writeInt(ndays); raf.writeInt(rate); raf.writeInt(totalCharge); raf.writeInt(discount); raf.writeInt(tax); raf.writeInt(netCharge); raf.writeInt(returnMileage); raf.writeBytes(carName + " "); //Closing the stream raf.close(); }
if (addrecord == true){System.out.printnl("record added");}
I close the interface then enter search for the record i just added using add record method but i do not find it what i am trying to say the added record using my application is not there. The question is how to save this record in the database ...
I have this very annoying issue with Eclipse (I have the latest version installed). For some reason, every time I use the "default" keyword in an interface, it gives me an error similar to "Syntax error on token default", I deleted the "default" keyword, the error is gone. The same thing happens with "Lambda expression as well", say I have this object like this :
Eclipse also displays the error message similar to "Method body expected after (), delete '->' ". I checked the Java version I have, it is the latest one also ....
I think I'm about 90% complete with this program but I'm stuck on my adding entries method. It gives me a runtime error which says:
Enter the name: Bill Exception in thread "main" java.lang.NullPointerException at Phonebook.addEntry(Phonebook.java:70) at Phonebook.main(Phonebook.java:49)
Here is my code: /* * This program asks the user for input for a name, phone number and notes up * to 200 entries. It stores every contact in a file. Type 'h' for help while * running this program. */ import java.util.Scanner; import java.io.*;
I believe I am on the right track but when I run the program I get an error that the class that I can't call on the method. I need to have what is selected in the JCheckBoxes added to the toppings array and I can't get that done what so ever.
Java Code:
import java.awt.event.*; import javax.swing.*; import java.awt.*; public class PizzaOrderListener { public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel();
I am writing a program in the GUI Builder and found that when I add code to print user input from text fields to a text file, the main method is no longer recognized. It throws all kinds of errors.
I have been able to get the code to work separately in a project file. Also, have been able to print to the console.
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;
i am having a below piece of code in my worker thread. In my output i am getting xml records from the database. I'm sending this output to a input stream & finally to a sax parser.My query is, before sending to the parser i need to store the input stream in buffer. The buffer should store 1000 records. For every 1000 records the parser should be called from buffer.
while (orset.next()) { output = orset.getString("xmlrecord"); writeCount++; InputStream in = new ByteArrayInputStream(output.getBytes("UTF-8")); InputStream inputStream = new ByteArrayInputStream(output.getBytes("UTF-8")); Reader reader = new InputStreamReader(inputStream,"UTF-8");
I am working on a project and for one step, I need to load an array (which in this case, students[]), with the records in another file.
So, should I used the try, catch method?? I am just not sure about the array. I know how to read from a file, but, I didn't get the idea of loading an array.
I am having some difficulty adding a new item to the HashTable when a collision occurs. We can only use the basic utilities to code this, so we are coding a HashTable by hand. We have an array of length of 10, which each index holds or will hold a Node for a Linked List.
The code hashes fine, adds the item, but the problem exists when adding items that already been hashed. The project is much bigger, but this is the engine behind the rest, and I figured I would tackle this first.
The items we are adding are objects which are states containing different information, we hash based on the ASCII sum % tableSize.
Here is the code I am testing with to add items:
HashTable ht = new HashTable(10); State az = new State("Arizona","AZ","W",2,"Y",2); State fl = new State("Florida", "FL", "F", 2, "X", 2); State hi = new State("Hawaii", "HI", "H", 3, "Z", 1); State al = new State("Alabama", "AL", "A", 5, "W", 0); ht.insert(hi);
So I am calling this method several times and trying to write multiple records to a file. Problem is that every time I call the method it overwrites the file from before and doesn't add it.
public void fileWriterMethod() throws IOException{ RandomAccessFile raf = new RandomAccessFile(filename, "rw"); raf.writeInt(id); raf.writeInt(existingMileage); raf.writeInt(gasCost); raf.writeInt(ndays); raf.writeInt(rate);
I am reading records from a txt file and storing it into an array
import java.util.*; import java.io.*; public class PatientExercise { //patients exercise time public static void main (String[]args) throws IOException{ Scanner in = new Scanner(new FileReader("values.txt")); double [] patientTimeRecords = new double [300]; int noExerciseCount=0, numPatients =0; double highest=0, lowest=0, avg=0, totalTime=0;
[Code] ....
However an error msg keeps popping up:
Exception in thread "main" java.util.NoSuchElementException at java.util.Scanner.throwFor(Scanner.java:907) at java.util.Scanner.next(Scanner.java:1530) at java.util.Scanner.nextDouble(Scanner.java:2456) at pastpapers.PatientExercise.main(PatientExercise.ja va:44)
line 44 is:patientTimeRecords[i]= in.nextDouble();
I need to view, update and insert records through a jsp page.example: Employee details..If we give an admission number of an employee, and if the admission number exists in the database then the details like Name, DOB, DOR, Address, Contact info should be displayed in the appropriate fields.(simply a select query in SQL) . The fields are editable and if we need to make any changes we can update in that details itself. If admission number doesn't exists means we can insert all the details except the admission number and a temporary admission number is generated and displayed. The problem with this is i can't able to revert it to the same page.
I am working on a Java program that calls a stored procedure in an Oracle 11.2g database and retrieves a set of records via a ref cursor. The program follows the standard Connection/CallableStatement/ResultSet pattern. A ResultSet object is used to access and iterate through the returned cursor, processing each record in turn.
One of the database fields returned in the cursor is a CLOB, which I'm retrieving using the NClob class's getNClob() method. Two other methods - length() and getSubString() are then used to get the length of the CLOB and copy of it off to a String object respectively.
The problem is that these latter two method calls are relatively slow, taking around 80ms to complete for modestly sized CLOBs of, say, around 10KB in size.
Is this the most efficient way to access a CLOB and retrieve its contents? If so, is there anything I can do, to make it run faster?
I'm new in JSF, so maybe this is a very simple problem: My small application actually uses 'primefaces ' and I'd like to display the course of some laboratory values this way:
I was trying to come up with the design for a library. Here are the requirements:
The library maintains a record of books and its members. It allows members to check out books. Books can be searched by author name or title. The books are classified into 4 categories - General, Sports, Politics, Business.
I've come up with this initial design:
Classes:
Category (enum)BookMemberLibrary Category Attributes: SPORTS, GENERAL, POLITICS, BUSINESS Book Attributes: String title, String authorName, Category category, boolean checkedOut
I have a need to refresh my database for every 15 seconds. I have to work with jsp ajax and jquery. For small amount of db entries it is ok but My application is going to handle huge records more than 20000. In my present scenario, Im forwarding request to another jsp page which communicate db and returns a table as result. Instead of this what are things I need to do?? This is just a sample application only. On success I am gonna implement using Spring, hibernate. So instead of table returning json or arraylist like that will work??
question: A stored procedure to insert records into deliveries table HINT create stored procedure with parameters for each field in the deliveries table for ex customer address, phone, email and receivers’s address etc this is my answer, this store procedure right or wrong. if wrong, can you share with me
create or replace PROCEDURE ADD_ORIENT ( EXCUSTOMER_NAME IN VARCHAR2 , EXCUSTOMER_PHONE IN VARCHAR2 , EXCUSTOMER_EMAIL IN VARCHAR2 , EXCUSTOMERRECEIVERADDRESS IN VARCHAR2 ) AS BEGIN NULL; END ADD_ORIENT;
Finding a strategy that allow process 12 millions of records in less than 1 hour. Each record can be modified by business rules. In this process are performed insert, update and select in other 3 tables.
The end result of this process is update monetary fields (for the calculations is used BigDecimal) of records in another table.
This process is part of the migration of Cobol to Java/Oracle. In cobol this process takes approximately one hour. Is it possible?
I have written a code to download .csv file with records from DB.
To download records i am uploading a .CSV file containing telephone number.
After downloading the .CSV file page is not getting refreshed.
Below is the code snippet i am using,where i am setting response content type as test/csv.
ServletOutputStream op = resp.getOutputStream(); // Set content type of output resp.setContentType("text/csv"); resp.setHeader("Content-Disposition", "attachment; filename="test""); op.flush(); op.close();
How that page will get refreshed after csv file download or after response.