Kassi Hill

Greenhorn
+ Follow
since Sep 29, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kassi Hill

I am trying to format a string using the SimpleDateFormat method and it is not working. I was hoping that someone more experienced could point out my problem. Thank you.

private String assignDate;

public void setAssignDate(String aDate){
try{
SimpleDateFormat fdate = new SimpleDateFormat("MM-DD-YY");
assignDate = fdate.format(aDate);
}catch (Exception e){}
}
19 years ago
I added the foundMatch(oneHotel); and that line compiled. Now when I try to loop through this array using:
for(int j=0; j<foundMatch.length; j++){
out.printlin(foundHotel(j));
}
I cannot get the loop to compile, can you see a problem with it??
19 years ago
I have a collection class that creates an array of objects in the constructor. I have a class that contains set and get methods to get the information out of the array created. I have another method that searches through the array for matches to what the user types in. If a match is found, then a boolean value is set to true and the matching inforation is printed out. What I need to do is put the matches found into another array and then loop through the foundMatches array. Below is the code that sets the boolean value, I cannot figure out how to then put the matches into another array.
for(int i=0;i<hotels.getSize();i++){
//verify hotels one at a time
Hotel oneHotel=hotels.getHotel(i);

if(oneHotel.getCity().equals(city)&&oneHotel.getState().equals(state)){
//if at least one hotel is found
found=true;
//print the information here.
This does work and I am able to get the information however, I need to be able to put it into a foundMatch arry to loop throuh to print out. Thank you for your help.
19 years ago
Anselm Paulinus,
Thank you very much. It worked.
19 years ago
JSP
Hi All. I am new to JSP. I am writing a very simple JSP that prints out all of the names of the parameters and values in a table.
I have posted my code blow, which does work, except that it prints each Heading and data cell in a seperate table. It does not print out all information in the same table. I know I am not looping through the parameterNames right but I just cannot figure out what I need to change. Any help would be appreciated.
<%
Enumeration parameterNames = request.getParameterNames();
while (parameterNames.hasMoreElements()) {
String parameterName = (String) parameterNames.nextElement();
String parameterValue = request.getParameter(parameterName);
%>
<table border = 1>

<tr>
<td><%= parameterName %></td></tr>
<tr>
<td><%= parameterValue %></td></tr>
<%}%>
</table>
19 years ago
JSP
Thank you for your help.
20 years ago
Thank you for your suggestions and I sorry I did not use the correct tags when posting my code. Actually, what my problem turned out to be was I was not closing my connection to the database in the right place. Thank you again for your help.
I am trying to insert information into an Access Table. If I hard code the variable information in, the insert statement works but when I assign the value of the ID number into a method to get a new number the update statement does not work. Any ideas??
This is the method I am calling to do the update:
WITHOUT CODE TAGS
public void addObject(){
int qID = getNewQID();\\get new ID number
System.out.println(qID);\\Used as a check and this is working
String qText = "Does this work yet?";
String qType = "false";
int qCorrect = 2;
String sql2 = "INSERT INTO Question(qID, qText, qType, qCorrect) VALUES("+ ID + ",'" + qText + "'," + qType + "," + qCorrect + ")";
//Send insert query to DataAccess Class to process
dataAccess.runUpdateQuery(sql2);
This is the method to get the NewID number:
public int getNewQID(){
WITH CODE TAGS

This is the method that should update the information in the Database:

public void runUpdateQuery(String sql){
try{
openConnection();//Open the Connection
stmt = conn.createStatement();//Create Statement Object
int s = stmt.executeUpdate(sql);
closeConnection();//Close Connection
}catch(SQLException sqle) {
System.out.print("Error in DataAccess: ");
System.err.println(sqle);
}//end try/catch
}//end runUpdateQuery
[ November 03, 2003: Message edited by: Gregg Bolinger ]
I was hoping someone could tell me if you could parse a long into an int and if you can, how you do it??
20 years ago
I need to write an SQL statement to get the Largest number out of an Access database table. I know it sounds simple but when I try "SELECT MAX (Question.qID) FROM Question"; this does not work, it says "Column Count not Found". If I run the query in Access then it works but I need to be able to get this number in JAVA so that I can then add one to it for a new id number. When I try just listing the id numbers in the table it works but when I add the MAX to the query I get an error. Thank you for your help!!
I have been trying something like:
private int getNewQID(){
int qID = 0;
String sql3 = "SELECT Max(Question.qID) FROM Question";
try{
rs = dataAccess.runSelectQuery(sql3);
while (rs.next()){
qID = (rs.getInt("qID"));
qID = qID +1;
System.out.println(qID);
}
}catch(Exception sqle) {
System.err.println("SQL NOT Executed: " + sqle);
}
return qID;
}
I am getting this error when I try compiling the program. I have not yet been able to send an actual statement yet because I have not been able to successfully compile the program.
I am trying to run an SQL update statement and I am passing the SQL as a string into a method. I am getting the following error message:
"DataAccess.java": Error #: 354 : incompatible types; found: int, required: java.sql.ResultSet at line 58, column 30"
I do not under stand the message, Your help would be greatly appreciated!!
This is the code:
public void runUpdateQuery(String sql){
//This method is called from the Business DataAccess Classes each time an
//Update needs to be made to the DataBase such as Insert, Delete statements
try{
conCounter ++;
openConnection();//Open the Connection
stmt = conn.createStatement();//Create Statement Object
rs = stmt.executeUpdate(sql
closeConnection();//Close Connection
}catch(SQLException sqle) {
System.err.println("SQL NOT Executed: " + sqle);
}//end try/catch
}//end runUpdateQuery
Thank you for your help!! This fixed my problem.
Good morning Ranchers. I am working a method that retrieves Questions from a Database. If the qType is False, then I need to select 3 chices from another table and load them into an Arrary.
I am having trouble. I am getting a Try without a catch error message but my try/catch is there. Also, when I do a second selection do I need to add a second try/catch??
Your help is GREATLY appreciated. Thank you.
Code:

[ October 21, 2003: Message edited by: Gregg Bolinger ]
Thank you very much. I works now.
Obviously, I am a newbie with JAVA and I can not tell you how greatful I am to have a place to go with questions!!!