User Profile
Collapse
-
Tomcat War issue
In my Tomcat 4.1.27 local development container (on Windows XP) I cant seem to get any of my War files to deploy. War files did work in the past and now anytime I put a War file in the webapps directory and stop and start Tomcat the War file doesnt create the new webapp directory. The autoDeploy is set to true in the conf/server.xml. Please advise how I can get War file to work? -
Best connection?
What is the best way to connect to a database in Java Class?
I have used 3 different ways and would like to know what is the most efficient one.
1- Put the connection as a data member:
[code=java]
public class DatabaseHelperC lass
{
private Connection connection = new DbConnectionMan ager().getConne ction();
public void insertDb(DbBean db) throws SQLException {... -
Thanks in my example I have a Database connection in my Constructor.
Is it not a good idea to put a Database connection in a Constructor?
Is the below way more efficient???
...Code:public class DbWork { private Connection connection = new ConnectionMgr().getConnection(); private PreparedStatement stat; public void cityInserter(FormBean city) throws SQLException -
Database helper class
I have a JDBC working with Oracle 9i in my Tomcat 4.1.3 Container.
The Database classes I have used for the past year are working great but I wonder if I should be closing anything in my database helper class with Prepared statements:
...Code:public class DbInsert { private PreparedStatement stat; private Connection connection; public DbInsert(Connection connection) -
Checking for duplicates
I currently have two String variables I check to find if they are duplicates:
Since red is not the same as yellow it would show "Not Duplicate".Code:String str1 = "red"; String str2 = "yellow"; if (str1.equals(str2)){ System.out.println("Duplicate"); } else{ System.out.println("Not duplicate"); }
... -
Duplicate data
I would like to make sure there are no duplicate data entries in my Oracle 9i table (called MainTable) which has an Id field that is the primary key, ValData with a varchar data type, Fid and Fid2 are number data types.
Sometimes someone can enter a duplicate ValData, Fid and Fid2...Code:Id ValData Fid Fid2 1 abc 34 2 2 efg 23 34 3 zeo 25 43
-
Ant or what I need?
I have been using Windows command window to compile my Java Classes for my Servlets, Java Beans and Helper classes. I use Studio as my IDE for creating the Java classes. Most of my Web Applications are just Forms feeding databases (using MVC) and I only have around 7 to 10 class files per Web application.
Should I start to use Ant and/or what is recommended so I can keep up with current technology instead of using Windows command window... -
Transaction attempt not working
I am trying to get Transaction working with JDBC and Oracle database. In my below example, if I try and fail the second insert by putting in an invalid table name (called BadTableName), the rollback doesnt work because the first insert makes it into the database. Please advise how I can get this to work:
...Code:public class Serra { .... public PreparedStatement prep; .. public int methodOne(City -
Get max id from a table
What is the best way to get the max id from a database table?
Here is how I am doing it now:
Code:Resultset rs = statement.executeQuery("select max(id) from TableMain"); rs.next(); int myMaxId = rs.getInt(1); //my insert sql is here to insert into another table the value of the max id (myMaxId) .... -
Combine methods
I have a 2 methods working in my class file that I am trying to convert into 1 method:
...Code:..... public Preparestatement prep; public int inserterOne(TheBean mybean) { int status = 0; try { prep.connection.preparestatement("insert into person (city, state) values (?,?)"); prep.setString(1,mybean.getCity()); prep.setString(2,mybean.getState()); -
Same ResultSet results references
Is it okay to keep creating queries with the same ResultSet Object reference (results)? Here is what I am currently using in my Database statements with Oracle and everything works but was wondering if this is okay where I am using ResultSet results for 3 queries in my Tomcat container:
...Code:ResultSet results = null; Statement statement = null; ...... statement = connection.createStatement(); -
Print Exception to Tomcat log file
I am trying to write a message to the Tomcat Log file (\Tomcat 5.5\logs) and it is not printing anything when I have a Rollback issue:
Code:... catch(SQLException e) { System.out.println("Database Rollback: " + e); } -
Thanks I got it to work just as you suggested.
Now I am trying the same thing with one more scriptlet in my JSP. But this JSP scriptlet has a for loop that outputs 10 links on the page:
...Code:<jsp:useBean id="pageinfo" class="storm.Pageinfo" scope="session" /> ..... <% if (pageinfo!=null) { for(int i=0;i < 10;i++)Leave a comment:
-
Yes, and I closed all connections which I didnt show in my example....Leave a comment:
-
Thanks for your response.
I actually did use an ArrayList to store the values and I appreciate your input about the large String[] type which I didnt know was smaller than the ArrayList type....Leave a comment:
-
Get rid of scriptlet and put in class
I have this scriptlet working in a JSP and was wondering how I can put it in a class file and call it in my JSP.
...Code:<jsp:useBean id="pageinfo" class="mypackage.PageInfo" scope="session"/> ... <% if (pageinfo!=null) { if (pageinfo.isFirst()) { out.println("<a href=first.jsp>first</a>"); } } %> -
Thanks, fake data for testing. I ended up using ArrayList add and get methods to get it to work....Leave a comment:
-
Get Database records instead of fake data
I have this part of a class that outputs fake data in my Tomcat 4.17 container.
Now I want to substitute the fake data for real data that fetches the field value of lastname records from the Oracle database, but not sure how?
...Code:public static final int INIT_SIZE = 32; private String[] strs = null; public MyContentGenerator() { strs = new String[INIT_SIZE]; for (int i=0; i<INIT_SIZE; -
Loop and Array issue
I have this JSP where I have alot of fields with conditions.
I would like to make it more efficient and use a for loop.
Here is an example (showing 2 fields for example only):
...Code:<%@ page language="java" import="java.util.*" %> <% HashMap errors = new HashMap(); String firstname = "Joe"; String lastname = "Miller"; if (!firstname.equals("")) -
Server Side Validation
I want to create a JSP Form page on Tomcat with a form that has about 10 input entries where the form will validate all 10 fields and show validation errors on the same page as the original form JSP page.
For example, if someone has a blank entry on the Firstname field then it will show this message in red next to the field: First Name is required.
If the data passes the validations it will populate an Oracle database....
No activity results to display
Show More
Leave a comment: