tathagata


{ City } kolkata
< Country > india
* Profession * s/w developer
User No # 16183
Total Questions Posted # 7
Total Answers Posted # 4

Total Answers Posted for My Questions # 40
Total Views for My Questions # 107072

Users Marked my Answers as Correct # 25
Users Marked my Answers as Wrong # 13
Questions / { tathagata }
Questions Answers Category Views Company eMail

What is the use of RequestDispatcher in servlet?

Accenture, CTS, TCS,

18 Servlets 50426

dear friends I have made connection with SQLSERVER where the following code is compiling properly but giving error at the runtime . I think error in this line where i am sending the value through string Connection connection = DriverManager.getConnection ( "jdbc:microsoft:sqlserver://localhost:1433","sa",""); import java.sql.*; //import mssqlserver.*; public class TestSQLCON { public TestSQLCON() throws Exception { // Get connection DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver()); System.out.println(); System.out.println("Successfully connected one"); System.out.println(); Connection connection = DriverManager.getConnection ( "jdbc:microsoft:sqlserver://localhost:1433","sa",""); if (connection != null) { System.out.println(); System.out.println("Successfully connected"); System.out.println(); // Meta data DatabaseMetaData meta = connection.getMetaData(); System.out.println("\nDriver Information"); System.out.println("Driver Name: " + meta.getDriverName()); System.out.println("Driver Version: " + meta.getDriverVersion()); System.out.println("\nDatabase Information "); System.out.println("Database Name: " + meta.getDatabaseProductName()); System.out.println("Database Version: "+ meta.getDatabaseProductVersion()); } } public static void main (String args[]) throws Exception { TestSQLCON test = new TestSQLCON(); } } so please help me

2 JDBC 4433

Life Cycle of Thread

IBM,

4 Core Java 9584

How can I make own ActionServlet? with example

IBM, TCS,

8 Struts 22591

I have getting problem to calling stored procedure from Mysql through JSP. Please help me.

1 JDBC 5884

How to send a request to garbage collector?

3 Advanced Java 3970

Can I create any Marker Interface? If yes then how can I use it???

4 Core Java 10184




Answers / { tathagata }

Question { TSYS, 11244 }

How to find total column from a resultset?


Answer

First one is the correct ans.2nd & 3rd will be return
toatal no rows not column.

Is This Answer Correct ?    0 Yes 1 No

Question { TCS, 66066 }

can you create interface instance ?


Answer

hi uday
I also tried this to call a interface of Collection and try
to instantiated but it is not working.
import java.util.*;
interface Test
{
public void wish();
}
class a implements Test
{
public void wish()
{
System.out.println("I am fine");
}
}
class Main
{
public static void main(String[] args)
{
Collection c =new Collection()
{
boolean isEmpty()
{
return true;
}
};
System.out.println(c.isEmpty());
Test t=new Test()
{
public void wish()
{
System.out.println("output:
hello how r u");
}
};
if(t instanceof Test)
{
System.out.println("t is a instance
of Test");
}
t.wish();
a oba=new a();
oba.wish();
}
}


But it is not working please explain.

Is This Answer Correct ?    2 Yes 0 No


Question { IBM, 22591 }

How can I make own ActionServlet? with example


Answer

please give detail ans with example if possible.

Is This Answer Correct ?    6 Yes 9 No

Question { Huawei, 8413 }

Write java code to print "Hello how are you"
Thread1 should have "Hello"
Thread2 should have "how are you"
both the threads should start at the same time


Answer

class Callme
{
synchronized void call(String msg)
{
System.out.print( msg
+ " ");
try
{
Thread.sleep(1000);
}
catch(InterruptedException e)
{
System.out.println
("Interrupted");
}

}
}
class Caller implements Runnable
{
String msg;
Callme target;
Thread t;
public Caller(Callme targ, String s)
{
target = targ;
msg = s;
t = new Thread(this);
t.start();
}
public void run()
{
target.call(msg);
}
}
class Synch
{
public static void main(String args[])
{
Callme target = new Callme();
Caller ob1 = new Caller
(target, "Hello");
Caller ob2 = new Caller
(target, "How are you");
// wait for threads to end
try
{
ob1.t.join();

ob2.t.join();
}
catch(InterruptedException e)
{
System.out.println
("Interrupted");
}
}
}


The above program will print Hello how are you with two
diff thread

Is This Answer Correct ?    17 Yes 3 No