This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clarifications on Java

 
Deepak Lal
Ranch Hand
Posts: 561
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have few Java Clarifications.Please guide me ....

1> Difference between Application Server and Web Server?

2> What is the difference between using
ArrayList list = new ArrayList(); and List list = new ArrayList();
Which one is better to use and Why?

3> Which is the driver which we use for JDBC
a>JDBC-ODBC bridge(Type 1 Driver)
b>Native API,Partly Java(Type 2 Driver)
c>Net Protocol,Fully Java(Type 3 Driver)
d>Native Protocol,Fully Java(Type 4 Driver)

Please help me out with the answers.

--
Deepak Lal
 
Ankit Garg
Sheriff
Posts: 9527
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Difference between Application Server and Web Server?


Well as far as I know, a servlet container is a web Server. For example Apache Tomcat. And an application server is a complete Java EE server like jBoss which supports EJB etc.

2> What is the difference between using
ArrayList list = new ArrayList(); and List list = new ArrayList();
Which one is better to use and Why?


Well when you use

ArrayList list = new ArrayList();

Then you are binding yourself to a specific implementation. But if you use

List list = new ArrayList();

Then you are using an interface to i.e. you are coding to an interface. In the latter case you get more flexibility. Lemme give you an example of when the latter might be useful. Suppose you have this code



Now suppose later on you decide that ArrayList is not suitable for your requirement as you need fast insertion and deletion. So you decide to use LinkedList. Now you will have to change the whole code



But if you code like this



Now if you decide to change ArrayList to LinkedList, then it will be easy

 
Vijitha Kumara
Bartender
Posts: 3914
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Lal wrote:
2> What is the difference between using
ArrayList list = new ArrayList(); and List list = new ArrayList();
Which one is better to use and Why?



Second approach is the way to go as you are coding to interface rather than to a specific implementation, later you can change to a different implementation without having to change other parts which uses the list reference.




 
Ankit Garg
Sheriff
Posts: 9527
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
3> Which is the driver which we use for JDBC
a>JDBC-ODBC bridge(Type 1 Driver)
b>Native API,Partly Java(Type 2 Driver)
c>Net Protocol,Fully Java(Type 3 Driver)
d>Native Protocol,Fully Java(Type 4 Driver)


I think you are missing something here. What is the database that you are using. If you are using MS SQL and configuring your connection in Administrative Tools in Windows, then it is Type 1 Driver. If any other, than it depends on the database software and the driver that you use.
 
Vijitha Kumara
Bartender
Posts: 3914
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Garg wrote:
Difference between Application Server and Web Server?


Well as far as I know, a servlet container is a web Server. For example Apache Tomcat. And an application server is a complete Java EE server like jBoss which supports EJB etc.



Well a servlet container is a Web Container not a Web Server. Web Servers are for serving static content (like html) like Apache Web Server.
 
Ankit Garg
Sheriff
Posts: 9527
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijitha Kumara wrote:Well a servlet container is a Web Container not a Web Server. Web Servers are for serving static content (like html) like Apache Web Server.


Hmm. Minute difference but still I didn't new it
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15435
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1> Difference between Application Server and Web Server?

See WebVsApplicationServer in our FAQ.

3> Which is the driver which we use for JDBC

That depends on what you need. The JDBC-ODBC bridge driver from Sun is not really meant for serious applications. A type 3 or 4 driver is usually good, because you don't need any special software on the client PC (for example, you won't need Oracle client software).
 
Deepak Lal
Ranch Hand
Posts: 561
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
Thanks for your valuable inputs and answers which helped me to understand the concepts.

1> I need the differences between Web Server and Application Server ?

@Jesper Young,Thanks for the FAQ,but im not able to figure out the differences clearly.Could you please provide me some differences.I'm confused with the FAQ.

3> So i can conclude that either type 3 or type 4 driver is used for JDBC with the database being oracle 9i.

--
Deepak Lal
 
Stephen Davies
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the difference between a web Server and Application Server?

A web servers main role is to handle requests from the web (predominantly http and https over TCP / IP) and provide appropriate responses. Its a common client-server pattern. An application Server may also be configured to do this, but more commonly it is used in the middle tier (think J2EE) to handle the business logic between the front end (e.g. a Web server) and the Back End (e.g. a database server). There are a vast number of protocols that can be used within an application server that are not necessarily used (nor available) to an web-server. Examples of Application Servers are GlassFish, (has built in WebServer capability) and WebSphere.

Tomcat is a Web Server of sorts, but mainly a Servlet Container. However, it may also be used as an add-in to other Web servers to Enable Servlet usage (For example Apache).
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15435
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's really simple: an application server is a web server which can run web applications on the server (for example servlets).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic