milil 24 Newbie Poster

You need to send that data from form to a page. So you need to add something like this:

<form id="contactform" method="post" action="localhostmmmmmmmm.com/update.php"> 

In my case action will send all that data in that update.php
So you need to add action to your form
Then when add it you need to make update.php you will getters for all taht fields

$option="";

if(isset($_POST["option"])) {
    $option=$_POST["option"];
}

That is one example.
Then you need to create sql code to update that in DB with exact ID of the row in table.
Try to do it by yourself if you once again have problems give us a code and we will help you.

milil 24 Newbie Poster

You can use Timer, with timer you can schedule one task to do every 10 secound or any amount of time you need.
Or if you need to wait for something you can use Thread with thread's sleep method to sleep your program for some amount of time and then when he wake up do something...
You need to specify what exacly do you need and we will help with coding. Mike.

milil 24 Newbie Poster

I had a same problem but i need a minutes, so you get a new time then subtract 1 hour or in my case 10 minutes from it and then you ask is that time greater then that time in database if it is you do what you want to do if not they your result from SQL will be nothing and that is it...
Code:

$newTime = date("Y-m-d H:i:s");

$timeLess10m = date("Y-m-d H:i:s", strtotime('-10 minutes', strtotime($newTime)));

$SQL="SELECT * FROM `DB` WHERE `ID` = 1 AND `TIME` < '" . $timeLess10m ."'";

$rez = mysql_query($SQL) or die("Error: ".mysql_error());
$num_rows = mysql_num_rows($rez);
if ($num_rows > 0) {
    // 10 minutes is passed
} else {
    // we are still in 10 minutes period...
}

I hope this would help, Mike.

milil 24 Newbie Poster

I think you need to subtract hours from main sum, then subtract minutes from the main sum and you will have secounds you need.
For examples you have 8000 secounds when you divede that with 60 to get minutes so you have 133.3 so now you need to divide that with 60 to get hours. Sou you get 2 hours.
You now calculate it like this 8000 - 7200 (2h represented in secounds) = so you have rest of 800 secounds. Now again divide it by 60 to get minutes you get 13.3 minutes now you use 13 minutes * 60 secounds you have 780 secounds sou you allready have 2 hours, 13 minutes and secounds you get by subrtacting 800 - 780 and you have 20 secounds...
You need to implement something like that. I wanted first to make you try to do that, if you again have trouble with code i will help you with coding...
Mike.

milil 24 Newbie Poster

You need to use SwingWorker. He is used for progres bars i think you can redesign it, so you can show message you want in seperate thread so your method will run free.

I used that to download picture from internet and in progres bar I will show how much proces is done. So your method will download everything you need and other will show message.

milil 24 Newbie Poster
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

did you add that line of code in your jsp page?

shwetha.marigowda commented: ya i have added that in starting itself, tag lib +0
milil 24 Newbie Poster

I give you something to work with, when you write something your own and find a problem i will help you.

milil 24 Newbie Poster

It can be anything you want it don't need to be array, and you don't need to worry about digits beucause this work like this:

String number = array[x] + "";
It makes string from number.

String firstTwoNumbers = number.substring(0,2);
It will get first two letters from that string, for example:
String number is "97112681919"
firstTwoNumbers will be: 9 (position 0) 7 (position 1) so you will get: 97

int numberLength = number.length();
This will calculate how much digits you have it can be 0 od 10000...0000 .

String lastTwoNumbers = number.substring(numberLength - 2, numberLength);
For last example "97112681919" it has 11 digits so what will this line code do. It will make substring from numberLength that is 11 - 2 so you get 9 and numberLength that is 11 so you will get string from 9 to 11 and that is digit on position 9 and position 10 so you will get: 19

If it can be anything you will need scaner to get input from your keybord and you need to define numbers and "compose numbers" so you can calculate.

milil 24 Newbie Poster

If it is a array it will be something like this.

int array [] = {9876,7698,7676,9898,987698,769876};

        for (int x = 0; x < array.length; x++) {
            String number = array[x] + "";
            String firstTwoNumbers = number.substring(0,2);

            int numberLength = number.length();

            String lastTwoNumbers = number.substring(numberLength - 2, numberLength);

            if (firstTwoNumbers.equals("98")) {
                // it starts with 98...
            }

            if (lastTwoNumbers.equals("76")) {
                // it ends with...
            }
        }
milil 24 Newbie Poster

I work with this driver: "mysql-connector-java-5.0.4-bin"
When you download that in .jar extension you copy that in your project.
Then if you are using Eclipse you right click on it, from meni go to Build Path, Add to build Path. With that you add that library to your project.
Then you can add my code from last post, that code is for some select queries...
And you can do that if you are using MySql database, if you are using something else you need driver specific for that database and code can be different...

milil 24 Newbie Poster

You need to add .jar from mysql driver to your project and then just do like this...

public static void main(String[] args) {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection conn = DriverManager.getConnection("server adress","username","password");
            Statement stmt = conn.createStatement();
            ResultSet rset = stmt.executeQuery("querry");
            while(rset.next()) {
                // do what ever you want...
            }
            rset.close();
            stmt.close();
            conn.close();
        }
        catch (Exception e) {
            e.printStackTrace();
        }


    }
milil 24 Newbie Poster

Length is number of values in array called args.

milil 24 Newbie Poster

You need to compile .jasper files into Jrxml source file (.jrxml)
Then you need to make servlet who will use .jrxml and make you pdf or something you want from them.
Try like that and if you still have problem let me know i will help you with some code...

milil 24 Newbie Poster

It is hard to secure your code, because no matter what you do to secure it, you can find something to undo it.
You can set some methods to get some data from database and if that data is ok you activate your app if not you stop it. Set that methods in few places in your code. You can check MAC address of computer and save it in database. If it is MAC ok than you start your app. There is a plugin which will shuffle your code and until you undo it you can't see you source code's.
Examples: System.out.println();
lnsyoutstem..pri.nt(;)
you will get someting like that.
If you have 500 lines in class it will be harder to resolve it but if someone wants to crack you app it will do it.

milil 24 Newbie Poster

Tomcat is server, so if you are deploying web app on the internet you just need to set a strong password for server and that is it. If you are developing it on localhost you don't need to worry because only you have access to that computer.

milil 24 Newbie Poster

I agree, but if you work with String (concating 1000 times) it is better to use StringBuilder because he is faster then String. Code example on this link:

milil 24 Newbie Poster

I work for a company who sell sms gateways if you need more info inbox me.

milil 24 Newbie Poster

I don't see logic with your question.
You post like user so you are redirecting to admin, user isn't same as admin so he can't do what admin can...

Hmm, you can do it in this way:
Make a table in database for BlogPost with fileds like createdBy, text, subject, published, etc...
Make a page for user to create a blog, when he add new blog it will add it in to database.
Next make page for admin that will go to database and search for all unpublished posts, executeQuerry that will find every blog where published is false...
Then add button or select when you press publish to make all of them published and the visitor of your website will see only published posts.

Or you can use Wordpress, he have allready implemented that. Bunch of users and admins, you can add restriction what they can do, and so many things...

milil 24 Newbie Poster

On this link you have example of mysql and mysqli...

milil 24 Newbie Poster

I think that you can do all that with team viewer and a program that will activate on startup, you can set your program to reactivate your connections and start team viewer program again...

milil 24 Newbie Poster

Because they have same value if you set one to "word1" and two to "word2" it will return false.
If you want to compare one and two as objects try this:

String one = new String("word");
String two = new String("word");

System.out.println(one.equals(two));
System.out.println(one == two);
milil 24 Newbie Poster

Hmm add semicolon at the end of the sql querry:

$qry = "select project from PROJECTS_PROJECT where project='ab1234';";

If that don't work hmm enter same sql in phpmyadmin so if it works you have problem with code, secound it can be mysqli problem I think that in older versions of PHP there is a cases when it won't work...

milil 24 Newbie Poster

If I understand your like of code right, you have servlet called student and you send them user and password for your database.
It will be something like this:

DriverManager.getConnection("jdbc:mysql://www.yourDomen.com/student?user=root&password=vibhuti");

When you buy your host you will need to buy domen as well so your new domen will be in every place you have localhost...

milil 24 Newbie Poster

You need to buy hosting for Java Tomcat or JBOSS I don't know what are you using and then you need to deploy your website to that server. There is a lot of available hosting but you should know, if you choose sharead hosting you can't make your own changes to server (Tomcat or JBOSS) because someone else is using it. And if you application crash for some reason or someone else's app crash it will crash all apps on that server, so my opinion is to buy your own server not shared, and you can set whatever options you want to it.
All hosting offer Mysql Database so you just need to create tables on that server and you can use it like that.
If you are using some files with relative path on server you need to find the path who will work because server start as root/web/etc/etc/...

I think that there is a optiong to make your own hosting but you will need static ip address, 24h computer, big upload and so much more ...

I think that is a best way to buy some java hosting or make it all work in PHP, PHP hosting is cheaper you can even find it for free...

milil 24 Newbie Poster

I am working for company who build sms gateway's but it isn't free product, if you need more detalis inbox me.

milil 24 Newbie Poster

You can write something like this:

<form method=post action="page.php" id='my_form'>
<input type="hidden" id="userName" name="userName" value="login_id" >
<input type="hidden" id="password" name="password" value="some_password" >
</form>
  <script>
    document.getElementById("my_form").submit()
  </script>

This will make form with some input fields and then call submit so it will redirect to another page. If you want to send some data with that form you can do it like this:

<input type="hidden" id="username" name="username" value="<?php echo $_POST['username']; ?>" >

so you will have text filed filled with value from your previous POST and then that value will be send to another page...

milil 24 Newbie Poster

You can't have method in method.
method1() and method2() are in public static void main() so compailer is complaining...
put method1 and method2 outside public static void main and it will be ok.

milil 24 Newbie Poster

Yes, on the link you have examples for "mysqli" and "mysql" connect they both work but if you have older versions of PHP server use "mysql" connect.

mysql_connect("host", "admin", "password") or die(mysql_error()); 

First you defind your host that is address from your server.
"admin" is your user who have access to database and "password" is your password for database. If you didn't put any password, they can be blank in many cases...
Then you connect to your database schema:

mysql_select_db("name_of_database") or die(mysql_error()); 

and then you can do some sql queries...

$data = mysql_query($sql) or die(mysql_error());
milil 24 Newbie Poster

Start with w3schools they offer great tutorial for beginers. For every "step" you have example how to do that so that is starting point. If you want that your new page look like previus you need CSS template just insert few lines of codes and that is it.
I will start with funcionality how to insert into database and when you finish it then work on how site will look. If you have more questions feel free to ask...

milil 24 Newbie Poster

On this link you can see connecting to database with host, username, password and database.

milil 24 Newbie Poster

If you want to learn best way is on w3schools.com. You have examples and tutorials how to do form with post or get methods and so much more. I think that you will learn faster if you go over that examples, and if you still have questions post a new question and we will help you.

milil 24 Newbie Poster

A few minutes on google and here you go...

import javax.sound.sampled.AudioInputStream;
   import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.Clip;

       try{
      AudioInputStream audioInputStream =AudioSystem.getAudioInputStream(this.getClass().getResource("path of relative sound file in src folder"));
     Clip clip = AudioSystem.getClip();
     clip.open(audioInputStream);
     clip.start( );
    }
   catch(Exception ex)
   {  }

Next time try to write your own code and if you came on problem then ask for help, I see that this is your first post so next time I want to se efford...

milil 24 Newbie Poster

Hmm first of all all version of Java can read SQL database you just need to add jar (for example: mysql-connector-java-5.0.4-bin.jar) and it will work, secound you can build Web Services in Java EE, main thing is that you have some methods that do some stuff and you "publish" them so anyone can call them (they can be called with other languages like C#, C, Delphi, etc...), so your android app will just call that metods you need...

milil 24 Newbie Poster

You need to write sql you need for that and you can make new page in php who will do that. On this link you have a pice of code that will insert user in table with username and password you can learn from that.

milil 24 Newbie Poster

Here you can see different algoritms for sorthing array's so you can sort row by row with this algoritms. Link.

milil 24 Newbie Poster

That is called "Cast". I will try to explain you. If you have array of class Object. Object class is parent class of every class in Java, so in that array you can put whatever you want...
So if you have on like this:
arrayOfObject[0] = 150; // int
arrayOfObject[1] = "Hello"; // String
arrayOfObject[2] = 1.441; // double
NamedCow n = new NamedCow();
arrayOfObject[3] = n;

And if you know what is in array you need to "Cast".
double newDouble = arrayOfObject[2];
but what will happen if you try this:
String newString = arrayOfObject[2];
You want String but array contains double. So he will ask you to cast it.
You can get to problem if you try to cast double into NamedCow:
NamedCow newNamedCow = arrayOfObject[2];
He will throw exception... So you need to know what is in array and cast it...

milil 24 Newbie Poster

Hmm I can't test it but i think it is all good, is StudentNumber unique?
If it is unique then it will update just 1 row because you have singe row with that value...

milil 24 Newbie Poster
int k = smt.executeUpdate("update pharmacy set mname='"+a2+"',desc='"+a3+"',amount='"+a4+"'where pid='"+a1+"'");

"mname" are you shure your field is called like that?

milil 24 Newbie Poster

No, but why would you do that? :D

milil 24 Newbie Poster

Hmm maybe your code do like it should, but did you check that they dont colide again? I see that you add random*5 +2 so is it possible that one of the ball be on position 1,1 secound 4,4 first go 2,2 second 3,3 they have "collision" then first go 3,3 second 2,2 another "collision" but it goes so fast you didn't see it?

milil 24 Newbie Poster

Hmm you don't need to worry about that because Java will, you can set it to import * but when you want to create .jar file Java will deploy classes that you need not all of them...
if you wan't to test it you can try it with * and when you import single files with this code:

long start = System.nanoTime();

// code to test

long total = System.nanoTime() - start;
System.out.println("Time needed for sorting: " + (total / 1000000.0));

And if difference is huge please tell us, I didn't test it but my profesor say that you can do it with star...

milil 24 Newbie Poster

I think that is better to create servlet in java and just send it to him a user and password, or maybe problem is in your password, i don't think that you can set password same as username... if you didn't set password i think that password is by deufalt "" empty string or nothing...

milil 24 Newbie Poster

Problem is because you do this: num1 = null; num2 = null; and you are calculating average with two null's you can't do that.

You need to do like this:

    import java.lang.Math;
    import java.util.Scanner;
    public class PairTest
    {
    private static double num1;
    private static double num2;
    private static double average;
    private static double distance;
    private static double maximum;
    private static double minimum;
    private static Scanner in;
    public static void main(String args[])
    {
    in = new Scanner(System.in);
    System.out.println("Please enter a value for the first number: ");
    num1 = in.nextDouble();
    System.out.println("Please enter a value for the second number: ");
    num2 = in.nextDouble();

    average = (num1+num2)/2.0;
    distance = Math.abs(num1-num2);
    maximum = Math.max(num1, num2);
    minimum = Math.min(num1, num2);

    System.out.println("Average: " + average);
    System.out.println("Distance: " + distance);
    System.out.println("Maximum Number: " + maximum);
    System.out.println("Minimum Number: " + minimum);
    }
    }
    }

So you declare average as double and you can't know num 1 and num2 so you need to read values from scaner and then calculate it when you get num1 and num2...

milil 24 Newbie Poster

You just go on your program you want to build as .jar.
Go File>Export>Runnable Jar and then you have options how to pack it...
Find what you want and it will automaticly include jdbc.driver in your .jar package...

milil 24 Newbie Poster

You need to make JTable with DefaultTableModel and AbstractTableModel and you have methods like:
public void fireTableChanged(TableModelEvent e) - Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model.
public void fireTableCellUpdated(int row,int column) - Notifies all listeners that the value of the cell at [row, column] has been updated.
Read documentation about DefaultTableModel and AbstractTableModel.

milil 24 Newbie Poster

Hmm, no, answer is correct. You can watch that as Folders in MyComputer,
You have C:\ then you have User\ then you have Smile\ then you have Movies\ so your path is C:\User\Smile\Movies\ and you see content on disk in that folder in Java is the same way, he goes throuh structure of your package and find last one, then he search for file you asked...

milil 24 Newbie Poster

Hmm, if you want to use someone's code you need that .jar package.
For example if you want to read email in Java you need mail.jar.
From mail.jar you get some implemented classes and you don't need to worry about that just see how to use it.
You can see example how to use mail.jar in your project on this link.
You just write code and import Session, Store, Folder and other stuff from that mail.jar and you need just to write method to use it...
So I think that you want to do exactly that just with other code...

milil 24 Newbie Poster

You can do like this:

for (int i = 0; i< vecA.size(); i++) {
            A newA = vecA.elementAt(i); // you get clas A 
            Vector newVector = newA.s; // you grab vector from clas A

            if (newVector.contains("String1")) {  // is that vector contains that string? ...
                System.out.println("We found it...!");
            }

}
milil 24 Newbie Poster

You dont use it well, try like this:

Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();

List<Company> lista = new ArrayList<Company>();
Criteria crit = session.createCriteria(Company.class);

if (true){ // you can add restriction like this name is passed in to method...
       crit.add(Restrictions.like("name", name).ignoreCase());
}
lista = crit.list();
sesija.getTransaction().commit();

And you can see a lot of examples on this link.

milil 24 Newbie Poster

You can do it in try block:

try { } catch (Exception e) { e.printStackTrace(); }

Or you can add on method throws IOException or what exception you need to catch...
You can write your own exceptions lik this:

class YourException extends Exception {
    YourException() {
        super("You can write your own message...!");
    }
}