Servlets & connection

We develop servlets and creation of connection was replaced in init() method. But if many people work at the same time
then Excpetion "not streaming mode" was generated.
public class viewReport extends HttpServlet
Connection conn;
public void init(ServletConfig config) throws ServletException
try
{super.init(config);
Class.forName (oracle.jdbc.driver.OracleDriver);
conn = DriverManager.getConnection (jdbc:oracle:thin:@Uran:1521:ORCL,
"scott", "tiger");
conn.setAutoCommit(false);
catch(Exception err)
If we remove
conn = DriverManager.getConnection (jdbc:oracle:thin:@Uran:1521:ORCL,
"scott", "tiger");
in the doGet() and doPost() methods nothing exception was trown.
Therefore it is necessary that One request = One connection. Is it true?
On the site Sun I read that we can create connection in the init() method. But this is not true in fact.
Thank you
null

"...I thought it would be easier if I just used a connectionpool.java file that i got from a book..."
I guess you'll find out. Depends on how good the book is, I guess.
.class files for Web apps always go in the WEB-INF/classes directory, of course. If they have a package statement, which they must for Tomcat, the package directory structure must be reproduced under WEB-INF/classes.
That's runtime. Compiling is different. The error is telling you that you didn't put that class in the CLASSPATH when you compiled:
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
MOD

Similar Messages

  • Midlet servlet connection

    Hi,
    I tried almost all the midlets servlet connection examples on various tutorial sites including sun's, they all run perfectly fine on J2ME wireless toolkit emulator but when I download them on Seimens SL45i with WAP connection , J2ME compliant and on O2 XDA pda with GPRS and CrEme virtual java machine and me4se library for MIDlet support its not working. If I connect PDA with PC using MS active sync, the MIDLet is able to connect with servlet or normal web page and retrive data from that perfectly, but when I remove the pda from docking station and run MIDlet, its not able to connect with servlet. Is there something more you have to do to access GPRS or WAP feauture of PDA/mobile phone.
    I am using normal HttpConnection to connect with the servlet.
    Thanks in advance
    Dhiraj

    I'm playing with some sockets.
    can you please help me?!
    J2ME uses only HTTP connections?
    and what are the sockets? what is the difference between CLDC socket and J2SE Socket?
    is there any other way to communicate with a Servlet?
    and very important..
    is there a difference if it's using GPRS or 3G?
    would the http connection work for all? and just the connection speed would change?
    help me!!

  • Exmpl of Servlet connect with ORacle

    Hi folks,
    Can anyone send me example of Java Servlet connectivity with Oracle.
    i m not able to connect servlet with oracle.
    u guys can reply me on [email protected]
    thanks
    dal hit

    No.
    The code for connecting to Oracle from a Servlet is no different from connecting to Oracle from any other Java application. So tell you what, you show us what you've tried and the error message(s) and we'll help you debug it.
    99.999% of the time it's a failure to put the driver Jar file into the classpath, the specifics of which vary from application server to application server. Which one are you using?
    u guys can reply me on [email protected]
    We can, but we won't. This is not your personal bugfixing service. Pay if you want that kind of help. If you want it for free, do it through the forums or go away.
    Probably you'll never read this response, but that's your problem not mine.

  • Servlet connection to mssql

    i want to connect servlet to mssql database on server.....i hv already created database from mssql server 2005....i hv written code for servlet.....but i dint getting wht should i write in Class.forname(); wht will be the URl also.....i hv sqljdbc.jar....how to do connection with database...

    try
      java.lang.Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
      Connection c = java.sql.DriverManager.getConnection("jdbc:sqlserver://MY-PC\\SQLEXPRESS;IntegratedSecurity=True");
      System.out.println("Connected!");
    }catch(Exception ex){
      ex.printStackTrace();
    }

  • Oracle Servlet Connectivity

    Hello
    When i try to connect my servlet with oracle it didnt detect oracle driver. My Simple java class was connect successfully but when i move to servlet i didnt work. Classnotfoundexception Occur tell me what i do and where i place classes12.zip folder in tomcat server.
    Thank You
    Regards
    Uzair

    Rename the classes12.zip to be classes12.jar
    Tomcat only reads jar files, not zip files.
    It should be in one of the following (in my order of preference):
    - web-inf/lib
    - TOMCAT/shared/lib
    - TOMCAT/common/lib
    Cheers,
    evnafets

  • ORA-12519 with servlet connect

    Hi,
    I'm facing a strange behaviour on my tomcat webserver with a servlet. I'm using Oracle 10g as the database and try to access it with my servlet.
    The doPost-method throws the following exception while trying to establish the connection to the RDBMS:
    "SQLException:
    Connecting not possible:
    Listener refused the connection with the following error:
    ORA-12519, TNS:no appropriate service handler found The Connection descriptor used by the client was: localhost:1521:DBTEN"
    After starting my servlet, the connection to the database for other applications blocks with the same error message
    for a few minutes. After these few minutes connecting to the database is possible again!!! Restarting the database and the listener also helps...
    public void doPost( HttpServletRequest request, HttpServletResponse response ) throws IOException, ServletException {
    Connection conn = null;
    response.setContentType( "text/html" );
    PrintWriter out = response.getWriter();
    String connStr = "jdbc:oracle:thin:@localhost:1521:DBTEN";
    try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    }catch( ClassNotFoundException cnf ){
    out.println( "CNFException: "+cnf.getMessage() );
    //retrieve Connection
    try{
    conn = DriverManager.getConnection( connStr, "scott", "tiger" );
    }catch( SQLException sqle ){
    out.println( "SQLException: <BR> Connecting not possible: <BR> "+sqle.getMessage()+"<BR>" );
    When I put that part in a 'normal' main program everything is ok. I can connect to the database and access tables with select statements and everything is ok.
    public static void main(String[] args) {
    Connection conn = null;
    //retrieve Connection
    try{
    String connStr = "jdbc:oracle:thin:@localhost:1521:DBTEN";
    try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    }catch(ClassNotFoundException cnf){
    System.out.println( "CNFException: "+cnf.getMessage() );
    conn = DriverManager.getConnection( connStr, "scott", "tiger" );
    }catch( SQLException sqle ){
    System.out.println( "SQLException:"+sqle.getMessage() );
    Does anyone have an idea what the problem is in this case?
    Regards,
    Lars

    "Note: The use of the DriverManager class to establish a connection to a database is deprecated." --
    http://download-uk.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25320/getconn.htm
    To open a connection use something like this:
    OracleDataSource ods = new OracleDataSource();
    ods.setUser("username");
    ods.setPassword("password");
    ods.setURL("jdbc:oracle:thin:@localhost:1521:XE");
    ods.getConnection();
    Instead of this:
    Class.forName("oracle.jdbc.OracleDriver");
    DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "username", "password");

  • JDBC/Servlets Connectivity Problems.

    Hi,
    I'm new to Java development.
    I'm trying to run this simple Servlet on
    OS : Sun Solaris 2.6
    Web Server : Netscape Enterprise Server
    Database : Oracle 8i
    JDK2 and JSDK2 installed on the Server.
    JDBC Driver : Native Oracle JDBC Driver
    This program works perfect on the Server if I run it as a program (Not a Servlet). However when running it as a Servlet, JUST DOESN't do ANYTHING. Doesn't return any error nor does execute the SQL Command.
    Also how can I enable tracing to Trap errors generated on the Server by the Servlet.
    Thanks for all your help....
    Here's the Pogram:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    public class CreateTable1 extends HttpServlet {
    public void init(ServletConfig config)
    throws ServletException {
    super.init(config);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    doGet(request, response);
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    ServletOutputStream out = response.getOutputStream();
    out.println("<html>");
    out.println("<head><title>CR2Reat Table Server</title></head>");
    out.println("<body>");
    out.println("<br>Before Create...");
    try {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection con = DriverManager.getConnection("jdbc:oracle:kprb:@oracle","uername","password");
    Statement statement = con.createStatement();
    statement.executeUpdate("CREATE TABLE kj_newCont1" +
    "(title_id NUMBER, title_name VARCHAR2(50)," +
    "rating CHAR(5), price NUMBER(7,2), quantity NUMBER," +
    "type_id INTEGER, category_id INTEGER)");
    catch (SQLException sqle) {
    System.err.println(sqle.getMessage());
    catch (Exception e) {
    System.err.println(e.getMessage());
    out.println("<br>AfterClose");
    out.println("</body></html>");
    out.close();
    public String getServletInfo() {
    return "Title Servlet return Information...";
    null

    To run servlets you must have a special server to run them like JRun or Java Web Server visit www.allaire.com to download JRun
    You must also download the servlet.jar
    java.sun.com
    you must configure your CLASSPATH too
    CLASSPATH=".:<path>classes12_01.zip":".:<path>servelet.jar"
    I'm using Red Hat Linux 6.2 I think this can Help you

  • Servlet connection refused: connect

    here my problem can any one help
    javax.servlet.ServletException: XML Parsing error: IOException: Connection refused: connect
         at net.athenet.cable.LocationSubmitAction.run(LocationSubmitAction.java:57)
         at net.athenet.cable.ControllerServlet.doPost(ControllerServlet.java:118)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:218)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:119)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:230)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocketAcceptHandler.java:33)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:831)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)

    I am using Jdeveloper 10.1.3.0.4

  • Servlet connecting to MS SQL

    Hi guys....... i am having problems connecting to MS SQL server. I think this may be due to the configuration of the USERID and PASSWORD during the ODBC setting, but after much meddling, it still didnt work. Below is e code i used.
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import com.internetcds.jdbc.tds.*;
    public class sample extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    try {
    System.out.println("Before Class " );
    PrintWriter out=null;
    Class.forName("com.internetcds.jdbc.tds.Driver");
    System.out.println("Before Connection " );
    java.sql.Connection Conn = (java.sql.Connection)java.sql.DriverManager.getConnection("jdbc:freetds:sqlserver:SQLServer","sa","password");
    System.out.println("Before Statement" );
    java.sql.PreparedStatement st = (java.sql.PreparedStatement)Conn.prepareStatement("select * from test");
    java.sql.ResultSet rs = st.executeQuery();
    while(rs.next()) {
    System.out.println(rs.getString(1));
    } catch(Exception e) {
    i haven got any error compiling
    but it dun seem to be able to read this line
    java.sql.DriverManager.getConnection("jdbc:freetds:sqlserver:SQLServer","sa","password");
    I dun think i downloaded any driver, but i did download the .jar file for it though
    Experts Please advice........ thanx

    IMHO you don't have to import the com.internetcds.jdbc.tds.* because you import it via
    Class.forName("com.internetcds.jdbc.tds.Driver");.
    Please print the stacktrace.
    Use
    } catch(Exception e) {
    e.printStackTrace()
    }instead
    } catch(Exception e) {
    e.printStackTrace()
    }and post the error message.
    Be sure that the lib from com.internetcds is in a directory from your webserver where it is loaded.
    Dietmar

  • Applet Servlet Connection

    Hi,
    I am trying to develop a chatroom application. I am using a applet as client which communicates with a servlet by recieving and sending a serialized object.
    This is done by using the URLConnection class.
    If one user send a message to the servlet then the servlet needs to send that message to all user in the chatroom.
    Herefore I need the connections to each applet. I need to store each connection to the applet of the user.
    How can implement this?
    Thanks

    Maybe you should open a socket connection from the applet to the servlet instead of using URLConnection. There is a tutorial on sockets on the java.sun.com site.

  • Applet to servlet connection failed using plugin 1.3

    Hi,
    I tried to send a serialized object from an Applet to a Servlet. It worked well until I installed the Java plugin version 1.3.
    Now I can open the Connection, create an ObjectOutputStream and write the object but nothing happens then. The Servlet doesn't start working.
    I don't receive an exception or error message, neither in Tomcat or Apache log-file nor in the plug-in console.
    here is my code example:
    String location = " http://localhost/com/spes/test/TestUploadSoundServlet";
    URL servlet = new URL( location );
    URLConnection servletConnection = servlet.openConnection();
    // inform the connection that we will send output and accept input
    servletConnection.setDoInput(true);
    servletConnection.setDoOutput(true);
    // Don't use a cached version of URLconnection.
    servletConnection.setUseCaches (false);
    servletConnection.setDefaultUseCaches (false);
    // Specify the content type that we will send binary data
    servletConnection.setRequestProperty ("Content-Type", "application/octet-stream");
    ObjectOutputStream out = new ObjectOutputStream(servletConnection.getOutputStream());
    out.writeObject(soundClass);
    out.flush();
    out.close();
    Is there anything wrong in the code above?
    thanks for help...
    mfg maze

    since the Apache server is listening on port 80 I thought it is not necessary to use the port number. I tried now with the new URL:
    String location = " http://localhost:80/com/spes/test/TestUploadSoundServlet";but it still doesn't work.
    thanks for your help

  • Problem with servlet connection

    Hi guys,
    Im gettin an nullpointer exception when connect to a servlet. Some "abstract" code:
    public void connect()
    servletConnection = servletURL.openConnection();
    servletConnection.setDoOutput(true);
    servletConnection.setUseCaches(false);
    servletConnection.setDefaultUseCaches (false);
    servletConnection.setDoInput(true);
    servletConnection.connect();     
    servletInput = new ObjectInputStream(servletConnection.getInputStream());
    public codeThatWorks()
    while(true)
    connect()
    usereceivedvalues();
    public codeThatDontWorks()
    connect()
    while(true)
    usereceivedvalues();
    I dont know why I have to reconnect to the servlet or renew the ObjectInputStream everytime I need to get values from it. Im using a ObjectInputStream to get the values from the servlet.
    Some ideas ? Thankss.

    I think your problem is in servlet. You can try the servlet without midlet in a IExplorer browser.
    ps1=con.prepareStatement("SELECT * FROM userLogin where uID=?");
    ps1.setString(1,uID);
    ResultSet re=ps1.executeQuery(); It is posible that re will be null.

  • Servlet -- Connection

    Hello to all, I',m presently working on an application involving servlets and odbc driver which is on a TomCat enviroment. I have 18 servlets that are called depending on what is needed to do, as for the connection, there is only one made .. once the user logs in. For the rest of the connection, I'm reusing the method from MyLogin.java (servlet) ...... ....
         public void init(ServletConfig config) throws ServletException
         super.init(config);
              c =MyLogin.getConnection();
    This process works fine for one user, but when there are 2 or more on line ..... I'm getting error messages!!
    Is this the way to go or should I create a new connection for each servlet

    It seems to me that your problem may be solved by using threads... but I'm no expert.

  • Problem create servlet connecting mysql

    Hello,
    I'm trying to create a servlet with JBuilder foundation.
    I've a java file, not included in the package of the JBuilder project and i want to deploi it on the Tomcat server (version 5.0). I 'Make' it and i deploy the .class.
    When i execute it I've the following driver error :
    java.sql.SQLException: No suitable driver
    I don't know what to do... :-(
    Thank you........
    My code:
    import java.io.*;
    import java.util.*;
    import java.net.*;
    import sun.beans.editors.IntEditor;
    import net.homeip.trv.util.*;
    import com.mysql.jdbc.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import com.mysql.jdbc.Statement;
    import com.mysql.jdbc.ResultSet;
    import java.util.Locale;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorldExample extends HttpServlet
    public void doGet(HttpServletRequest request,
    HttpServletResponse response) throws IOException, ServletException
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    //-------------------------------start MySQL connection-----------------------------
    ResultSet rs = null;
    String queryString = "";
    String url = "jdbc:mysql://localhost:3306/db_client";
    String user = "root";
    String password = "root";
    try
    Class.forName("com.mysql.jdbc.Driver");//.newInstance();
    catch (ClassNotFoundException ex2)
    String msg = "";
    Connection con = null;
    try
    con = (Connection) DriverManager.getConnection(url, user, password);
    catch (SQLException ex1)
    msg += ex1;
    }

    I've to deploy it in the same place of .class ?No, you should create a war (or ear) file, and place the driver jar in the correct location of that file.
    http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/WebComponents3.html
    Kaj

  • Rtp servlet connection

    Hi there, i am trying to make a video chat with jmf. For this i am using servlet to spread video coming from
    desktop. Generally we use servlet request in order to start a servlet for processing.
    But when we use rtp how can we connect to a servlet to send datastream or video?

    waynres wrote:
    i am trying to connect to a servlet from desktop.Aim;
    desktop client sends a video stream to servlet, servlet sends it bak to desktop.But here
    i am using dynamic ip to connect internet and i am writing rtp:/myDynamicip:port for data transfer.
    Firstly i make a http request to servlet. then transmitting starts.No...not exactly.
    The HTTP request just ensures the servlet is up and running. It shouldn't kick off any kind of action.
    1. can servlet send data back to this ip?Yeah, if it responds to the same IP/PORT that it got the request from, it can send packets that say they are from the address the original request went to.
    IE, if the servlet responds using the same IP/PORT combination that it receives data on, and it just replies to the from ip/port number it gets in the request packets, then the responce packets will make their way back to the client...
    2. if i put receive and transmit code in servlet does it work?It should, yeah.
    3.How can avoid servlet to kill after a period of time orI don't know. I believe that servlets that are actively doing stuff don't get killed. I could be wrong.
    4. is there any way except servlet to route video stream as server ?Eh, if you just wanted to use a servlet to kick-off the connection between two clients, and just have the video go from peer-to-peer, you could do that too.

Maybe you are looking for

  • [SOLVED] Booting windows 7 kills Arch

    Hi, I'm dual booting Arch with windows 7 and recently when I boot windows 7, I can't boot Arch afterwards. After I shutdown windows, I start up my laptop again, I get the grub menu and select Arch. During boot I get a lot of output during the file sy

  • Entries in T510 are not getting defaulted in IT0008

    Hi Experts, Entries maintined in T510  are not getting defaulted in IT0008. According to the wagetype model  (LGMST - Feature ) the wage types are defaulting accurately  but the amount is coming blank. Please advice. Regards, IFF

  • Problem moving pages within a pdf

    I have been working with a fairly large document (around 1500 pages) and it is impossible to re-order the pages.  An example: I will drag page 12 to page 2, and when I release the mouse button, the page will be at page 18.  Inserting from a file lead

  • Implementing WebDynpro ABAP in JAVA Portal

    Hello We have a JAVA enterprise Portal and we would like to create an iView of WebDynpro ABAP application. We have done it in our QA portal by creating a system and in the property editor configuring the "Web AS Host Name" & "Web AS Path". It works g

  • Can we download  item categories & item category groups from R/3 to CRM

    Hi, Can we download  item categories & item category groups from R/3 to CRM ? If yes pl share the adaptor object name. Thanks, Regards, PV