IE vs NN

I am using "sun.jdbc.odbc.JdbcOdbcDriver" for my applet for connecting the database.  This works fine for NN. But not for IE.
For IE I have to use "com.ms.jdbc.odbc.JdbcOdbcDriver" provided by the Microsoft.  Now what extra coding(whether in the html file or applet file)  I have to do if I want my applet works fine for both NN and IE at the same time depending the users browser.
jmaruthikumarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ravindra76Commented:

0
Ravindra76Commented:

0
Ravindra76Commented:
Hi  jmaruthikumar,

  What ?......................

First forget about NN and IE.

Concentrate on Applets and Databases.

 Are you using  JDBC-ODBC bridge in Applet to connect  to database and it has to be executed in both.

There are four types of  JDBC drivers. Refer this URL

http://java.sun.com/products/jdbc/drivers.html 


JDBC-ODBC drivers come under type 1 driver.
Type 1 and 2 driver are not useful for applets to connect to database.

Type3 and Type 4 allow applets to access database with Zero installation. They won't require Class.forName(":....");


They requirement is presence of classes in client side is must for JDBC-ODBC drivers.

You know that Applets will execute on Client side even though they have came from server.

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") -  In NN
Class.forName("com.ms.jdbc.odbc.JdbcOdbcDriver") -- IN IE

So browser will look for these classes on clinet side.

How are you sure that all the clients running your applets are loaded jdbc-odbc bridge classes in their machine.

At first Class.forName will work onlu You have given unlimittted access to applets. The default Security manager will Throw error if use Class.forName.

The solution is Using Type 3 and Type 4 drivers.

Best of luck.
 






0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

jmaruthikumarAuthor Commented:
Hi Ravi,

Thanks for ur suggestion.

But Class.forName("..."); is a must irrespective of the type of driver using, whether it is type 3 or type 4. I used type 4 drivers provided by the third parties with zero-client installation. But those are expensive.(I used trail versions).

By default, Jdbc-Odbc driver won't support networking.(Pl.check the following: http://java.sun.com/products/jdbc/faq.html#5 )
If it want to support, we have to create same DSN(DataSource) on each and every Client machine.  Since IE uses its own JVM it doesn't support Jdbc-Odbc.  

Regards
Maruthi.
0
Ravindra76Commented:
Hi jmaruthikumar,

 In Type 3 and 4 , the classes are coming on fly to the applet.
The required classes will now come server instead of client.
Class.forName("..."  classes came from server );

But with JDBC-ODBC the case is different. At first some settings has to be done on client side. They must be present in clinet.
Like type 3 and 4, server won't send the on fly.

My doubt is, How can you make settings if you are using applets on internet?.

That's why jdbc-odbc solution is not suitable.

We won't foce the clinets to make the required settings
0
Ravindra76Commented:
Hi jmaruthikumar,

 In Type 3 and 4 , the classes are coming on fly to the applet.
The required classes will now come server instead of client.
Class.forName("..."  classes came from server );

But with JDBC-ODBC the case is different. At first some settings has to be done on client side. They must be present in clinet.
Like type 3 and 4, server won't send the on fly.

My doubt is, How can you make settings if you are using applets on internet?.

That's why jdbc-odbc solution is not suitable.

We won't foce the clinets to make the required settings
0
jmaruthikumarAuthor Commented:
Hi Ravi,
I agree with u.  What u said is right.
But I had developed applet for intranet with Jdbc-Odbc(since type 4 is expensive) we have to create DSN on each client machine.  
Now I want to work my applet with something like this:
If the user is using NN
{
   Class.forName("load sun jdbc-odbc driver");
}
else
if the user is uisng IE
{
    Class.forName(" load MS jdbc-obc driver");
}
Is this possible? If yes how?
0
jmaruthikumarAuthor Commented:
Hi Ravindra,
If am I right u r a telugu guy.
I have some queries regarding Java.
I want to share them with u.
I too working on Java in a MNC in B'lore(India).
my mail id:jmaruthikumar@hotmail.com
pl. keep in touch
maruthi.
0
Ravindra76Commented:
Hi jmaruthikumar,

 You are correct.I was born in Andra pradesh

 To solve your problem we have to see any propery so that
 applet can know from which browser it was loaded.

If we don't know, there is a silly solution. Don't laugh at it

try {

   Class.forName("Load nn driver");
  Class.forName("Load IE driver");

}
catch ( NoClassDefFoundException notfound){

}
catch ( Exception ee) {
  ee.printStackTrace();

}

Any how one driver will be loaded. If another driver isnot present means ignore the exception

Best of luck

0
sameerjoshiCommented:
On the browser, when the applet is loaded, you can pass the type of browser, IE or Netscape in the init method and then can the load the appropriate class as need as follows:


if(navigator)
   Class.forName("Load nn driver");
else
   Class.forName("Load IE driver");


Anyway here is the code to detect the browser type.......



import java.applet.*;

public class BrowserDetector extends Applet
{
       public void init()
       {
            if ( isNetscape() )
              System.out.println("This browser is a Netscape Browser.");
           if ( isMicrosoft() )
              System.out.println("This browser is a Microsoft Browser.");
          }
                             
        public static boolean isNetscape() {
              try {
                                Class.forName("netscape.applet.MozillaAppletContext");
                                }
                              catch (ClassNotFoundException e) {
                                System.out.println("This browser is not a Netscape Browser.");
                                return false;
                                }
                              return true;
                              }    

                            public static boolean isMicrosoft() {
                              try {
                                Class.forName("com.ms.applet.GenericAppletContext");
                                }
                              catch (ClassNotFoundException e) {
                                System.out.println("This browser is not a Microsoft Browser.");
                                return false;
                                }    
                              return true;
                              }    
                          }
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sameerjoshiCommented:
To be of more use to you here is the link for you to check

http://www.codeguru.com/java/articles/548.shtml


Enjoy....

Na telugu talli......
0
mbormannCommented:
hey sameerjoshi tu marathi ahes ka?
kutha rahatos?
We are all INDIANS man,I live at Thane,Maharashtra.

Ravindra ,thanx for providing links.
jmaruthikumar : I may have a query for you.I will ask you sometime next week ,shall I mail at that account you provided?

Regards
Amit
0
sameerjoshiCommented:
Kai mhanta AMit Kularni saheb !!! Kai chaalu aahe??
Well I stay I at California. How are u doing????? I see that you are doing well at this site with your name in top 15 experts.I am really happy to see an Indian in the top.

0
mbormannCommented:
Sameer,
evijay is also indian.and he is also very good.

ani me kahi saheb nahi ahe mala phakt 11 mahinya cha experience ahe in java.anyway what abt u?if u wanna talk ,mail me at that address amitkulz@hotmail.com
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.