Lap Lap - 5 months ago 9
SQL Question

Result into my input

I want to pass a query to SQL Server and in that query, i want to pass some data to database.

But the problem is that i want to take input from user as(example just for understanding you):

String Info = u.next();


and pass that input result
Info
into a query.For example

Info = "Jon";


and that input
Jon
should be pass to the database through query.

Answer

You can do also as:

public String getHostName() {
String hostName = "";
try {
    java.net.InetAddress addr = InetAddress.getLocalHost();
    hostName = addr.getHostName();
} catch (UnknownHostException ex) {
  System.out.println("Hostname can not be resolved");
}
return hostName; }