peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Interesting behaviour, I was thinking that repeated assignment in this scenario is fine as basically this should repeatedly overwrite that single object of names array. We will have wait and see if anyone knows...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I do not know if you have hard-coded path to folder or not, but once you have path tot the folder you can use File class method list() or listFiles() . First returns array of Strings and second returns array of File objects. Use which ever you prefer, reading files then become simple...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I tried to modify the code for Oracle db.But it not works properly.

Modified what exactly and what is not working? Provide full description and any related errors you receive. We are not mind readers here to know what is happening on your side...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

First part yes, second part no and yes (principle of connection with DB is same for all just connection string does vary) but answer is here if you cared to actually search before posting

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

1) Learn more about Java web development, these days people do not use out.print to display HTML tags
2) Divide your code in according to Model-View-Controller
3) Have look on good tutorial, like this one or even better learn how to use Apache Commons

shalabhgarg commented: thanks +0
kvprajapati commented: Good advice. +6
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

>Java DB 10.4.2.1: I assume that's Java's database, which I don't use and should be able to remove, unless Java uses it internally.
Just leave it, you may want ot use it in the future

>Java(TM) 6 Update 6: I assume that is the JDK that I am using.
Not sure why you have this update since your original instalation seems to be the one bellow

>Java(TM) SE Development Kit 6 Update 16: This could be my culprit. Right. And I should remove it. Right?
Definitely keep it

>Java(TM) SE Runtime Enviroment 6 Update 1: I can remove this also, Right?
This can go

If you want to be on safe side you can delete them all and install JDK 6 Update 17 and update JAVA_Home and PATH, but that decision is really up to you. Option two, install JDK 6 Update 17 with NetBeans 6.7.1

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

PATH is C:\Program Files\Java\jdk1.6.0_16\bin
JAVA_HOME is C:\Program Files\Java\jdk1.6.0_16 (without "bin folder at the end)
CLASSPATH is not need it since Java 1.4

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

What do you find wrong in my way of communication and typing??Could you please tell me ??:?:

Consider using less of colourful text, start using full sentence English and provide as much information as necessary when trying to get something sorted.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

So if you have written that code why didn't you posted so somebody can have look at it and tell you what can be wrong?
So far it does look like you posted your assignment and expect somebody else do it for you...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

The code is local to your machine so we would not be able to see the code till you post it...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

moved

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

We may never know as Rahul002 was so rude as to never reply what he/she is up to...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Yes sure...

To buy these projects, please contact us on ABCDEF or mail me at : dump at dump dot com.

These prices are valid for a limited time period. So hurry to grab it.

You must be real dump not to see the sarcasm of request...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

As you already found out you can not check for something that is not there, something you did not declare.
You may consider simple work around like this if (i+1 != nubArr.size()) taking in consideration that i+1 can only be smaller than or equal to array list size, as for loop will not let you go over array list size

ryno365 commented: Helped me with a problem. +1
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@Thirusha correction, you can do DB connectivity with AJAX which is essentially JavaScript ;)

sknake commented: nice to see you solving in the mssql forum :) +6
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

In your project create create new package "lib". Right click on the project and select Properties. In the pop-up window, in CATEGORIES (left side listing) select Libraries & Resources >>on the right press Add JAR/Folder and navigate to place where is the driver or any other library you wish to add >> highlight file/s you want to include and press OK.


However if the projects are just learning (no-production) you may want to just create a directory somewhere on the disk that you can re-use for attaching Connector/J. In this scenario just skip the section for package creation and go directly for adding resources.

javaProgrammar commented: peter is a good programmer. I like suggetions posted by him. +0
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Ahh hell, I forgot about connector and it dependency on classpath.
To beat this either set classpath or use following in command prompt/line

//compile
javac MysqlTest.java -cp mysql-connector-java-5.0.8-bin.jar
//execution
java MysqlTest -cp mysql-connector-java-5.0.8-bin.jar

Change the name of the application and driver name in regards what you have.

import java.sql.*;

   public class MysqlTest
   {
       public static void main (String[] args)
       {
           Connection conn = null;

           try
           {
               String userName = "root"; //change it to your username
               String password = ""; //change it to your password
               String url = "jdbc:mysql://localhost:3306/test";
               Class.forName("com.mysql.jdbc.Driver").newInstance();
               conn = DriverManager.getConnection(url, userName, password);
               System.out.println("Database connection established");
           }
           catch (Exception e)
           {
               System.err.println("Cannot connect to database server");
           }
           finally
           {
               if (conn != null)
               {
                   try
                   {
                       conn.close ();
                       System.out.println("Database connection terminated");
                   }
                   catch (Exception e) { /* ignore close errors */ }
               }
           }
       }
   }
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If you checked box in installation to set path for MySQL you need to only call mysql -u USERNAME -p followed by password after system request. In case you didn't do it, you need to navigate command prompt/line down to home directory of your MysQL and from there execute the above command

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Dunno why people insists on installing MAMP/WAMP/XAMP when they are about to do Java development and they do not need PHP and Apache.
Now you need to figure out on which port is your instance of MySQL running and each time you try to work with database you will need to have your Apache server running.
Solution delete MAMP and install MySQL only.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Any specific reason you used 8888 for port number? MySQL is by default installed on 3306.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Please provide connection strings as you tried including exceptions you received.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Putting anything in default Java installation directory is bad idea. If you creating just simple application you can keep JAR file in same directory as your source code for easy compiling. However while working on something larger you should set up special folder for any external resources ("lib") and either manage linking to your project through IDE or with Ant or Maven configuration files (which IDE basically does for you on background).

Your mistake as already pointed was in use of incorrect connection string that should be

//Pseudo code
jdbc:mysql://<HOST>:<PORT>/<DB>
//Example code
jdbc:mysql://localhost/danijsptutorial
//or with port number if database uses other then default port
jdbc:mysql://localhost:3306/danijsptutorial

Examples of connection string for other databases can be found here

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If Tomcat been installed through IDE it may have assign different port then 8080 or 80. Check it with server.xml file that is inside conf folder of your Tomcat directory

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
  • Guess it will be down to the fact we have here nice rule - We only give homework help to those who show effort that you ignored.
  • Next OP already had two hints how to approach this problem, therefore your solution wasn't necessary.
  • Lastly our suggestions been better in comparison yours where if user provide number in different format then 4 digits program will not work correctly

Do you still believe that person who down-voted you made wrong decision?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

beside JAVA_HOME do you have set PATH in system variables as C:\Program Files\Java\jdk1.6.0_16\bin ?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Be creative, for example if you read input from user you will get string object. Convert string to character array, read array element by element, convert element to integer and fine out if it is odd or even number.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Sorry, I cannot help right know (little busy at the moment), but you can have look at Beginning J2ME: From Novice to Professional Chapter 12 that should help with device discovery

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

No JavaFX is just add-on with NetBeans instalation. Did you set path to your installation of Java like in the first part of this article (up to point 3)?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

So is this solved now or there is something else you want to ask?
If it is solved, please mark it as solved by clicking on "Mark as Solved" bellow last post.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

NO there aren't any free ebooks that are legal however there is Android Essentials and Android: A Programmer's Guide with limited preview from Google Books

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Sorry for that....
I have written the cod ein net beans....here am trying to connect to MYsql database and retrieve data from there...........
The errors that iam receiving are

com.mysql.jdbc.JDBC4Connection@c58418

Failed to initalize plugin: org.jboss.logging.Log4jLoggerPlugin@12a74c7, cause: org/apache/log4j/LogManager

You did not imported Logger into your code as other packages

import org.jboss.logging.Logger;

Full JBoss documentation on topic here
EDIT:
You actually tried but did it wrong import java.util.logging.Logger;

am also getting this error

A message body writer for Java type, class Programs.ProgramDetailsList, and MIME media type, application/xml, was not found

am unable to figure out whether am going wrong in my code or is there
some jar files missing

Full error description as given by compiler plus relevant coding need to see what is going on. You should know this...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You have two instances of bold tag left in wrong places see code bellow.

<DIV style="LEFT: 30px; POSITION: relative; TOP: 65px; visibility: visible;" id="buttonUp"><A 
onmouseover=javascript<b></b>:scrollUp() onmouseout=stopScroll() 
href=#><IMG src="http://romboy.oxyhost.com/up.gif" width=13 
height=13 border=0></A> </DIV>
<DIV style="LEFT: 30px; POSITION: relative; TOP: 290px" id="buttonDown"><A 
onmouseover=javascript<b></b>:scrollDown() onmouseout=stopScroll() 
href="#"><IMG src="http://romboy.oxyhost.com/down.gif" width=13 
height=13 border=0></A> </DIV>

As for the JPGs I do not see problems there. Maybe you misspelled image name, file extension or made mistake with actual path. Also I see you are using absolute path to the documents like in this case

<img src="C:\Users\SonnyDajAlexa\Desktop\test\smiley.jpg" alt="ROMboy.co.cc" title="ROMboy.co.cc" border="0" width="350" height="45">

which would create absolute nightmare to sort out when you upload it on net. It is better to stick to relative path. So if image is same level as html document "name.jpg" is fine, if image level up then "../name.jpg" and for level down "level/name.jpg".

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Problem description is missing, how we are supposed to know what sort of errors you getting. Plus there is no chance to second-guess what you trying to achieve...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Is the problem occurring only on sites you create or in any website. If it is only your creation then we need to see code...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Remove "<Student>" from ValidRecords class opening, problem solved...

package Assignment;

import java.util.*;
/**
 *
 * @author Nigel Novak
 */
public class ValidRecords {

    // Class Fields and Constants Follow
    private ArrayList<Student> list;
    private int sortOrder;
bentlogic commented: lightning quick solution; wish i'd emailed Peter earlier! +1
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You should posted in JavaScript section not in JSP that stands for Java Server Pages. Post moved...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Edit: Ignore this, masijade already spotted error
First check your name spelling for tables and columns used if you have any spelling mistakes (can check it as you failed to provide database or affected tables specs)

In the future please post full error message not just section.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

An easier way to start and stop tomcat is using the Tomcat Monitor. I think during the installation of tomcat it asks you if you would like to install that monitor . However if you did not choosed to install that.. you can go to the bin folder of your tomcat installation and start tomcat6w.exe It sits on your system tray and you can open it anytime to start and stop tomcat with a GUI.

Depends on the type of installation package you choose. If you go for windows installer you loosing capability to use your instance of Tomcat with IDE(Eclipse, NetBeans, IntelliJ IDEA) as this require startup.bat and shutdown.bat presence

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You need to pay closer attention to opening and closing of brackets. See bellow code (the code still will not compile and throw some errors which you need to solve)

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;

public class Calculator extends JFrame implements ActionListener{

    private JTextField displayText = new JTextField(30);
    private JButton[] button = new JButton[16];

    private String[] keys = {"7", "8", "9", "/",
    "4", "5", "6","*",
    "1", "2", "3", "-",
    "0", "C", "=", "+"};

    private String numStr1 = "";
    private String numStr2 = "";

    private char op;
    private boolean firstInput = true;

    public Calculator () {
        setTitle("Calculator");
        setSize(230, 200);
        Container pane = getContentPane();

        pane.setLayout(null);

        displayText.setSize(200, 30);
        displayText.setLocation(10,10);
        pane.add(displayText);

        int x, y;
        x = 10;
        y = 40;

        for (int ind = 0; ind < 16; ind++) {
            button[ind] = new JButton(keys[ind]);
            button[ind].addActionListener(this);
            button[ind].setSize(50, 30);
            button[ind].setLocation(x, y);
            pane.add(button[ind]);
            x = x + 50;

            if ((ind + 1) % 4 == 0) {
                x = 10;
                y = y +30;
            }
        }

        this.addWindowListener(new Window Adapter()) {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        }
    };

    setVisible(true);

//}

    public void actionPerformed(ActionEvent e) {
        String resultStr;

        String str = String.valueOf(e.getActionCommand());

        char ch = str.charAt(0);

        switch (ch) {
        case '0' :
        case '1' :
        case '2' :
        case '3' :
        case '4' :
        case '5' :
        case '6' :
        case '7' :
        case '8' :
        case '9' :
        if (firstInput) {
        numStr1 = numStr1 + ch;
        displayText.setText(numStr1);
        }
        else {
        numStr2 = numStr2 + ch;
        displayText.setText(numStr2);
        }
        break;

        case '+' :
        case …
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

i couldnt start the server...i tried using commands in dos like.."tomcat start".The url i used was http://localhost:8080/

You would have to set path to tomcat for the command to be recognised in similar manner to what you did with Java so now you can call "java" or "javac" commands.
To start Tomcat without need of messing with path is either go to the location of startup.bat (or startup.sh under Unix/Linux) and then just execute "startup" or call startup file with absolute path such as "C:\Tomcat6.0.20\bin\startup"

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You got general direction of the wind that files that you wish to deploy should be placed in webapps folder, unfortunately it is not full truth.
You need to provide your "ch" folder with minimal Tomcat deployment directory structure.

  1. Create new project folder in directory webapps (you already did this with creating new folder named ch)
  2. Place context.jsp in "ch" folder (you already did)
  3. In project folder create another folder called WEB-INF where you will save web.xml
  4. Create web.xml
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">
    
    <web-app>
    <welcome-file-list>
    	    <welcome-file>context.jsp</welcome-file>
    </welcome-file-list>
    </web-app>
  5. Start server and call your JSP
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You can do it your self ;)

Just click on "Mark as Solved" under last post...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You cannot throw exception on class. You can make class throw exception with use of try catch block (often followed by finally)

Scanner inFile;
    try{
        inFile = new Scanner(new FileReader(infile));
    }
    catch(FileNotFoundException e){
        e.printStackTrace();
    }

or directly from method

public Scanner getBook() throws FileNotFoundException{}

but then you will need to catch possible exception on the receiving which is supposed to receive Scanner object back from getBook() method.

So remove exception from class header and handle it by one of the above ways.

PS: Also I'm not sure what you trying to do on line 17&18. Are these just some de-relics from past or are they have so other purpose?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I have no idea what I'm looking for as I do not see any use of outFile.print(); or PrintWriter outFile = new PrintWriter(outfile); However what I see here is intentionally another problem

public class Address
{
	//Declare variables
	String street;
	String city;
	String state;
	String zip;
	String phone;
	static Scanner console = new Scanner(System.in);

	//Constructor
		public Address(String st, String ct, String sta, String zp)
		{
			String street = st;
			String city = ct;
			String state = sta;
			String zip = zp;
		}
		Address()
		{
		}

Even though you declare global variables street, city, state, zip these are never initialized because you create another identical set inside your constructor. This is called shadowing and it happens when you redeclare a variable that’s already been declared somewhere else. The effect of Shadowing is to hide the previously declared variable in such a way that it may look as though you’re using the hidden variable, but you’re actually using the shadowing variable.
So the above should be corrected either by removing type declarations inside constructor or use of setter methods

public class Address
{
	//Declare variables
	String street;
	String city;
	String state;
	String zip;
	String phone;
	static Scanner console = new Scanner(System.in);

	//Constructor
		public Address(String st, String ct, String sta, String zp)
		{
			street = st;
			city = ct;
			state = sta;
			zip = zp;
		}

		Address()
		{
		}
public class Address
{
	//Declare variables
	String street;
	String city;
	String state;
	String zip;
	String phone;
	static Scanner console = …
BestJewSinceJC commented: good response +4
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You are not paying attention to your tags formatting, if they have all double quotes as need it, if the tag is correctly closed and if they are in right order

<html>
<head>
<title></title>
</head>
<body>
  <form name="frm_details" method="post" action="mailto:someone@hotmail.com"> 
     <table border="1" width = "100%">
      <tr>
        <td>Name</td>
        <td><input type="text" name="name" size="30"/></td>
        <td>ID</td>
        <td><input type="text" name="Id" size="25"/></td>
      </tr>
      <tr>
        <td>Password</td>
        <td><input type="text" name="password" size="30"/></td>
        <td>Address</td>
        <td><textarea cols="30" rows="2" name="address"/></textarea></td>
      </tr>
        <td>Sex</td>
        <td><input type="radio" name="sex" value="male"/>Male
            <input type="radio" name="sex" value="female"/>Female 
        </td>
        <td>Marital Status</td>
        <td><select name="marital status" size="1">
            <option value="Single">Single</option>
            <option value="Married">Married</option>
            <option value="Divorced">Divorced</option>
            </select>
        </td>      
     </tr>
     <tr>
       <td>Phone</td>
       <td></td>
       <td>email</td>
       <td><input type="text" name="email" size="30"/></td>
     </tr>
    </table>
    </form>
</body>
</html>
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
  1. Tags which do not have pair close tags should have back slash on the end of their declaration, which all of yours input tags are missing
  2. Input for ID is missing double quote after size declaration
<html>
<head>
<title></title>
</head>
<body>
  <form name="frm_details" method="post" action="mailto:someone@hotmail.com"> 
     <table border="1">
      <tr>
        <td>Name</td>
        <td><input type="text" name="name" size="30" /></td>
        <td>ID</td>
        <td><input type="text" name="Id" size="25"/></td>
      </tr>
      <tr>
        <td>Password</td>
        <td><input type="text" name="password" size="30"/></td>
        <td>Address</td>
        <td><textarea cols="30" rows="2" name="address"/></td>
      </tr>
        <td>Sex</td>
        <td><input type="radio" name="sex" value="male"/>Male
            <input type="radio" name="sex" value="female"/>Female 
        </td>
      </tr>
    </table>
    </form>
</body>
</html>
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

No offence, but looking on your posting history I'm not sure if you actually posted in correct section.
Are you sure you talking about Java as programming language by Sun Microsystems or you wanted to ask about JavaScript as scripting language mainly used for web development.

Either way more explanation need it in regards what you did so far...

PS: If this is in wrong section you better to hit "Flag Bad Post" option and request to move it in right section, before you get slag from others

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Welcome back dude