DialUp Connection using Java

Dear friends
I am facing problem,How to get DailUpConnection in Java .Is there any APIs which provide the DialUpConnection.
Please mention the API's or Sample code .
thanks

As the previous reply states, my computer has been configured to automatically connect using dial up services, whenever windows determines a connection is needed.
I was wrong to say that Java does this. However, I just thought it might be easier for you to configure you internet connection to automatically connect when needed.
When I run the following program an automatic connection is made. If I am not configured for automatic dial up, then a dialog box is displayed asking me to connect:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.HttpURLConnection;
public class URLTester
     private final static String PROTOCOL = "http://";
     public static void main(String args[])
          if ( args.length != 1 )
               System.out.println("Usage: java URLTester <url>");
               System.exit(-1);
          String urlString = args[0];
          try
               // Create URL object from the URL string
               URL url = new URL(PROTOCOL + urlString);
               // The connection object has information that my be
               // retrieved without parsing the data returned
               HttpURLConnection conn = (HttpURLConnection)url.openConnection();
               conn.connect();
               // Get an input stream from the URLConnection object
               // Note: if you dont need connection information you can get an
               // input stream from the URL object ( url.openStream() )
               InputStreamReader isr = new InputStreamReader( conn.getInputStream() );
               BufferedReader in = new BufferedReader( isr );
               String line;
               while ( (line = in.readLine() ) != null )
                    System.out.println( line );
               in.close();
          catch(IOException e)
               System.out.println( e );
}

Similar Messages

  • Crystal Reports data connection using Java beans

    Hi
    My name is Bach Ong, i'm currently perform re-configuring Crystal reports 2008 to connect via
    Java bean to Jboss server, this uses look up service on JBoss server. The connection is using Connect
    look up using the properties:
    java.naming.provider.url=jnp://emgsydapp121:10499
    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
    for file CRConfig.xml i put as follows:
    <JDBCURL></JDBCURL>
    <JDBCClassName></JDBCClassName>
    <JDBCUserName></JDBCUserName>
    <JNDIURL>jnp://emgsydapp121:10499</JNDIURL>
    <JNDIConnectionFactory>org.jnp.interfaces.NamingContextFactor
    y</JNDIConnectionFactory>
    <JNDIInitContext>/</JNDIInitContext>
    <JNDIUserName></JNDIUserName>
    Can you advise us if this step is correct, and is there any
    documentation that can guide us to right direction.
    for Java testing in Eclipse using remote call class it is working suing the following code:
            Properties p = new Properties();
            p.put(Context.INITIAL_CONTEXT_FACTORY,
            "org.jnp.interfaces.NamingContextFactory");
            p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
            p.put(Context.PROVIDER_URL, "jnp://emgsydapp121:10499");
             InitialContext ctx = new InitialContext(p);
      Date asAtDate = CrystalUtils.convertToDate("2014-01-01", CrystalUtils.relativeToToday(0), false);
         String asxCode = "BHP";
         ClosingPricesReportRequest criteria = new ClosingPricesReportRequest(asAtDate, asxCode);
         InitialContext context = new InitialContext(p);
         ClosingPricesReportService ejb = (ClosingPricesReportService) context.lookup(ClosingPricesReportService.REMOTE_JNDI);
         ClosingPricesReport report = ejb.createMTMClosingPriceReport(criteria);
         System.out.println(report.getClosingPrices()[0].getClosingPrice());
         testval = report.getClosingPrices()[0].getClosingPrice().toString();
         System.out.println(testval);
    when i run the tes code the results as follow:
    10:49:45,244 DEBUG [SecurityAssociation ] Using ThreadLocal: false
    10:49:45,338 DEBUG [MicroSocketClientInvoker ] SocketClientInvoker[709446e4, socket://emgsydapp121:10473] constructed
    10:49:45,338 DEBUG [MicroRemoteClientInvoker ] SocketClientInvoker[709446e4, socket://emgsydapp121:10473] connecting
    10:49:45,338 DEBUG [MicroSocketClientInvoker ] Creating semaphore with size 50
    10:49:45,338 DEBUG [MicroRemoteClientInvoker ] SocketClientInvoker[709446e4, socket://emgsydapp121:10473] connected
    10:49:45,369 DEBUG [ClientSocketWrapper ] reset timeout: 0
    10:49:45,650 DEBUG [InvokerRegistry ] removed SocketClientInvoker[709446e4, socket://emgsydapp121:10473] from registry
    10:49:45,650 DEBUG [MicroSocketClientInvoker ] SocketClientInvoker[709446e4, socket://emgsydapp121:10473] disconnecting ...
    10:49:45,650 DEBUG [SocketWrapper ] ClientSocketWrapper[Socket[addr=/10.137.2.40,port=10473,localport=64150].2cba5bdb] closing
    37.99000000000000198951966012828052043914794921875
    37.99000000000000198951966012828052043914794921875
    Can anyone assist me in convert the above settings to get access by Crystal reports.
    My attemp current are below:
    public class CFDClosingPricesRpt extends CrystalReport {    
        //Constructor
        public CFDClosingPricesRpt(){
            super(ClosingPriceBean.INSTANCE);
         * Returns the ResultSet for this report to Crystal.
         * @param asxCode
         * @param asAtDateString
         * @return
    public ResultSet getNewReport(String asxCode, String asAtDateString) {                     
         try {
             Properties p = new Properties();
             p.put(Context.INITIAL_CONTEXT_FACTORY,
             "org.jnp.interfaces.NamingContextFactory");
             p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
             p.put(Context.PROVIDER_URL, "jnp://emgsydapp121:10499");
             //InitialContext ctx = new InitialContext(p);
             clearCachedReportBeans();     
       Date asAtDate = CrystalUtils.convertToDate("2013-01-01", CrystalUtils.relativeToToday(0), false);
          asxCode = "BHP";
          ClosingPricesReportRequest criteria = new ClosingPricesReportRequest(asAtDate, asxCode);
          //ClosingPricesReportService ejb = (ClosingPricesReportService) ctx.lookup(ClosingPricesReportService.REMOTE_JNDI);
          ClosingPricesReportService ejb = (ClosingPricesReportService) ServiceLocator.getInstance().getService(ClosingPricesReportService.REMOTE_JNDI);           
          ClosingPricesReport report = ejb.createClosingPriceReport(criteria);
          // assemble Crystal-friendly DTO
          Collection closingPrices = Arrays.asList(report.getClosingPrices());
          for (Iterator iter = closingPrices.iterator(); iter.hasNext();) {
                    MBLXClosingPrice cp = (MBLXClosingPrice) iter.next();               
                    if (cp==null) continue;               
                    addReportBean(new ClosingPriceBean( report.getSuppliedDate(),
                                cp.getClosingPrice(),
                                cp.getAsxCode()));
      } catch (Throwable x) {     
          saveErrorMessage(x);
      return getAsResultSet();             
    Thanks
    Bach Ong

    Hi Don Thanks for the reply.
    I've was able to connect via Java beans and JNDI. But this one is going the JNDI of JBoss sever, which the JNDI already configure and working for Crystal reports v10.
    Bach

  • Measuring performance tcp udp connection using java

    ho
    find t answers for these questions ..
    1. Is it possible to set some upper cut off for the data rate or transmission rate in TCP or UDP ?
    2. IF true, get t source code for t same ?
    3. is it possible to measure t data rate of a TCP or UDP connection ?
    4. get t compl source code for broadcasting using java ?
    sry im learning to use java sry if my questions are rookie and absurd . .
    pl bear wit me . .
    thank u in advance . .
    bye bye

    hi ebj and kayaman ,
    thanks for the reply for my first question . .
    "No, but you can limit the receive window which can have a similar effect."
    my second question was ...
    can help me out by giving the java code for the first question`s solution ?
    and my third question ...
    Is it possible to measure the throughput / transmission rate in which the udp or tcp transfer is taking place ??
    i think i ve made myself clear to you guys ..

  • AIR application and database connectivity (using JAVA)

    Hi
    I am creating AIR application and I want to connect with the database using java database connectivity (JDBC).
    Can any body give me the some suggestion on how to how to do that.
    Please give me any reference for creating AIR application for database connectivity with mysql/access.
    Thanks
    Sameer

    lots of serching on the google and found that For AIR applications either you use Webservices(JAVA/PHP/.Net) or you can use SQLLite.
    Not found any method for direct connectivity with the database using JDBC.
    If any one found direct connecivity withe database using JAVA then please reply.
    Thanks

  • Unable to establish SSL connection using Java PKCS11

    I am currently trying to establish SSL connectivity using eToken via PKCS11.
    The PKCS11 provider is setup and I can read the 3 stored certificates as a key Store Object.
    But I am getting the following exception while trying to establish SSL connectivity.
    I am using JDK 6.0(java version "1.6.0_31-rev).
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.security.InvalidKeyException: Unsupported key type: SunPKCS11-aladdin-0 RSA private key, 2048 bits (id 147980297, token object, sensitive, unextractable)
    at sun.security.mscapi.RSACipher.engineGetKeySize(RSA Cipher.java:384)
    at javax.crypto.Cipher.b(DashoA13*..)
    at javax.crypto.Cipher.a(DashoA13*..)
    Code:
    KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
    KeyStore keyStore = getClientKeyStore(); //read Smart Card Token to get the Certificate
    kmf.init(keyStore, "mycardPin".toCharArray()); //#### hard coded the i/p parms
    TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
    KeyStore trustStore = KeyStore.getInstance("JKS");
    trustStore.load(new FileInputStream("C:\\Users\\usr1\\Desktop\\Certifi cates\\mycertca.jks"), "mycardPin".toCharArray());
    tmf.init(trustStore);
    SSLContext sslContext = SSLContext.getInstance("TLS");
    sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
    factory = sslContext.getSocketFactory();
    sslClient = (SSLSocket) factory.createSocket(host, port);
    sslClient.startHandshake(); //<--- code is breaking here with the above exception
    I am struggling like anything for the last 4 days to get rid of this issue. Please let me know is there any work-around to fix this issue.
    I really appreciate your help.

    Hi,
    have You found the solution. I have similar problem but now it is not repeatable. I'm not sure what was the reason (this InvalidKeyException apeared only once). I'm using JDK7 (java version 1.7.0_09-b05).
    Caused by: java.security.InvalidKeyException: Unsupported key type: SunPKCS11-GemSafe RSA private key, 1024 bits (id 2, token object, sensitive, unextractable)
         at sun.security.mscapi.RSACipher.engineGetKeySize(RSACipher.java:404)
         at javax.crypto.Cipher.passCryptoPermCheck(Cipher.java:1052)
         at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1010)
         at javax.crypto.Cipher.init(Cipher.java:1209)
         at java.security.Signature$CipherAdapter.engineInitSign(Unknown Source)
         at java.security.Signature$Delegate.init(Unknown Source)
         at java.security.Signature$Delegate.chooseProvider(Unknown Source)
         at java.security.Signature$Delegate.engineInitSign(Unknown Source)
         at java.security.Signature.initSign(Unknown Source)
         at sun.security.ssl.RSASignature.engineInitSign(Unknown Source)
         at java.security.Signature$Delegate.engineInitSign(Unknown Source)
         at java.security.Signature.initSign(Unknown Source)
         at sun.security.ssl.HandshakeMessage$CertificateVerify.<init>(Unknown Source)
         ... 53 more

  • CORBA Connection using Java ORB

    Has anyone had any experience connecting to a CORBA object published in an Oracle 8.1.5 database using a different ORB than the visigenic ORB?
    I've been able to connect using the visigenic (Oracle-flavor) ORB from my workstation when I compiled and executed with JDK 1.1.8.
    But the project I'm working on requires Java 2. The CORBA classes in Java2 prevent me from using the available visigenic classes so I am attempting to use the Java2 ORB.
    Does anyone know the steps necessary to accomplish this?
    Thanks,
    Jonathan Keller
    Web Application Developer
    U.C. Davis

    Thanks Sandeep,
    Though I don't know which APIs to use here, but i have seen MDM 7.1 does support SSO, and it has some connection constructor that needs just the user name and not the password for creating user session, if such is the case, i think it would be convenient to get the logged in user id from user session and then use it to create the user context.
    Regards,
    Nitin
    Edited by: Nitin Mahajan on Jan 3, 2009 7:10 AM

  • Ftp connection using java

    Hi All,
    I need to upload a file through ftp connection uisng java calss. any one know please reply me
    Thanks
    K.Kalikumar

    Hi Kali,
    I have worked on similar issues sending you the code.. hope it should work. I had written a TelnetInterface class where I did all operation inside the constructor.
    import javax.servlet.http.HttpSession;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.InputStream;
    import java.io.PrintStream;
    import org.apache.commons.net.telnet.TelnetClient;
    public class TelnetInterface {
         private TelnetClient telnet = new TelnetClient();
         private InputStream in;
         private PrintStream out;
         private String prompt = ">";
         private boolean isConnected ;
    public TelnetInterface(){
         public TelnetInterface(HttpServletRequest request) {
                   HttpSession session = request.getSession();
                   PropertyReader propReader = (PropertyReader)session.getAttribute("propReader");
                   String host=null,user=null,password=null,port=null;
                   int unixPort= 0;
    //                Get Unix credentials
                   if(propReader != null){
                        host=(String)propReader.getProperty("UNIX_HOST");
                        user=(String)propReader.getProperty("UNIX_UNAME");
                        password=(String)propReader.getProperty("UNIX_PWD");
                        port=(String)propReader.getProperty("UNIX_PORT");
                        unixPort = Integer.parseInt(port) ;
    //                    Connect to the specified server
                   System.out.println("Inside telnet Interface");
                   try{
                        telnet.connect(host, unixPort);
                        isConnected = true;
                        in = telnet.getInputStream();
                        out = new PrintStream(telnet.getOutputStream());
    //                    Log the user on
                        readUntil("login: ");
                        write(user);
                        System.out.println("user:"+ user);
                        readUntil("Password: ");
                        write(password);
                        System.out.println("password:"+ password);
                        sendCommand("su - loginuser");
                        su(" password");
                   }catch (IOException e) {
                        e.printStackTrace();
                        isConnected = false;     
                   }catch (Exception e){
                        e.printStackTrace();
         }

  • Problem w/ a dialup connection and Java web site sessions timing out.

    Anytime a web site that uses a Java in a pop up box times out, the longer the time afterwards that there is no user response the worse the problems get.
    The page freezes, then the browser, it can't be closed w/o using task manager,
    The dialup adapter freezes (cant be disconnected).
    It doesn't seem to happen with a broadband connection.
    I have tried XP Pro w/sp2, XP Pro w/sp1a, 2000 w/ sp4 and all have the same problem.
    I have tried a different hardware modem (orginal is a software modem) and the same thing.
    I have tried older versions of Java, but the same. thing.
    This happens on two different boxes (motherboards).
    The sites involved are Yahoo card games chat sessions & Ameriatrade stock quotes sessions. The ISP is Earthlink.
    Normal surfing is unaffected. This happens with Firefox & Opera and I believe Idiot Exploiter (whichisn't used).
    One box is a Dell/Wintel and w/ the orginal setup (XP Home modified by Dell), worked w/ no issues. Dell says Java V1.5 was used (which I tried). I don't thik it is a O/S issue.
    Regarding older versions of Java, anyone suggest one that doesn't have these issues??
    BTW, no viruses and these were all fresh installs w/ the latest drivers.

    In a thread about problems with Yahoo, someone noticed that your session can prematurely time out if you have set proxy to auto-detect here:
    orange Firefox button ''or'' classic Tools menu > Options > Advanced > Network > "Settings" button
    Could you test with the setting on No proxy or Use system proxy settings and see whether it helps?

  • AS/400 connectivity using java by jt400 api

    I am making a project on Java Swing. I am having an AS/400 machine i am saving the spool files on AS/400 Machine as .txt and accessing it from a remote Windows Machine. I have made an UI to connect it to the AS/400 machine using JT400 API's. I am having 300 spool files(.txt) in the library on AS/400 machine. I m accessing this library to get the list of spool files basically .txt files. Now I am using JT400 OpenAsynchronously method but the program gets hanged over there and displays on 25 files. I don't know what to do please help
    Akhil
    Code:--------------------------------------------------
    public Vector listSpooledFiles()
    Vector rowData = new Vector();
    // this.printQue = printQue;
    try
    String strSpooledFileName;
    boolean fCompleted = false;
    int listed = 0, size;
    System.out.println(" inside method....1");
    //System.out.println("Now receiving all spool files synchrously");
    SpooledFileList splfList = new SpooledFileList(as400);
    splfList.setUserFilter(userId);
    //if((printQue.equalsIgnoreCase("*ALL"))||(printQue.equals("")))
    //if((printQue.equalsIgnoreCase("*ALL")))
    splfList.setQueueFilter("/QSYS.LIB/%ALL%.LIB/%ALL%.OUTQ");
    // else
    //splfList.setQueueFilter("/QSYS.LIB/%LIBL%.LIB/"+printQue+".OUTQ");
    //splfList.setQueueFilter("/QSYS.LIB/%LIBL%.LIB");
    // wait for the list to complete
    //splfList.waitForListToComplete();
    // add the listener.
    System.out.println(" inside method....2");
    splfList.addPrintObjectListListener(this);
    System.out.println(" inside method....3");
    // open the list, openAsynchronously returns immediately
    splfList.openAsynchronously();
    System.out.println(" inside method....4");
    do
    System.out.println(" inside do....1");
    // wait for the list to have at least 25 objects or to be done
    waitForWakeUp();
    System.out.println(" inside method....1.2");
    fCompleted = splfList.isCompleted();
    System.out.println(" inside method....1.3");
    size = splfList.size();
    System.out.println(" inside method....1.4");
    System.out.println(size+"::size of files");
    //System.out.println("sizeOfList......"+size);
    // output the names of all objects added to the list
    // since we last woke up
    while (listed < size)
    System.out.println(" inside method....1.5");
    if (fListError)
    System.out.println(" ..Exception on list - " + listException);
    break;
    System.out.println(" inside method....1.6");
    SpooledFile splf = (SpooledFile)splfList.getObject(listed++);
    } while (!fCompleted);
    System.out.println(size+"::Size");
    //splfList.removePrintObjectListListener(this);
    System.out.println(" inside method....1.7");
    Enumeration enum = splfList.getObjects();
    System.out.println(" inside method....1.8");
    while(enum.hasMoreElements())
    SpooledFile splf = (SpooledFile) enum.nextElement();
    if(splf != null)
    Vector tmp = new Vector();
    String fileName = splf.getStringAttribute(SpooledFile.ATTR_SPOOLFILE);
    int fileNo = splf.getNumber();
    String jobName = splf.getJobName();
    String jobUser = splf.getJobUser();
    String jobNo = splf.getJobNumber();
    Integer page =splf.getIntegerAttribute(SpooledFile.ATTR_PAGES);
    String date=splf.getStringAttribute(SpooledFile.ATTR_DATE);
    String time=splf.getStringAttribute(SpooledFile.ATTR_TIME);
    date=date.substring(1);
    StringBuffer sbdate= new StringBuffer(date);
    sbdate=sbdate.insert(2,"/");
    sbdate=sbdate.insert(5, "/");
    StringBuffer sbtime=new StringBuffer(time);
    sbtime=sbtime.insert(2,":");
    sbtime=sbtime.insert(5,":");
    date=sbdate.toString();
    time=sbtime.toString();
    if((!fileName.equals("QPJOBLOG")) && (!fileName.equals("QPDSPJOB")) && (!fileName.equals("QPSRVDMP")))
    // For the JCheckBox
    tmp.addElement(new Boolean(false));
    tmp.addElement(fileName);
    tmp.addElement(new Integer(fileNo));
    tmp.addElement(jobName);
    tmp.addElement(jobUser);
    tmp.addElement(jobNo);
    tmp.addElement(page);
    tmp.addElement(date);
    tmp.addElement(time);
    rowData.addElement(tmp);
    splfList.close();
    catch( ExtendedIllegalStateException ex )
    System.out.println(" The list was closed before it completed!");
    catch( Exception e )
    // ...handle any other exceptions...
    e.printStackTrace();
    return rowData;
    //return arrRowData;
    // This is where the foreground thread waits to be awaken by the
    // the background thread when the list is updated or it ends.
    private synchronized void waitForWakeUp()
    throws InterruptedException
    // don''t go back to sleep if the listener says the list is done
    if (!fListCompleted)
    wait();
    // The following methods implement the PrintObjectListListener interface
    // This method is invoked when the list is closed.
    public void listClosed(PrintObjectListEvent event)
    System.out.println("*****The list was closed*****");
    fListClosed = true;
    synchronized(this)
    // Set flag to indicate that the list has
    // completed and wake up foreground thread.
    fListCompleted = true;
    notifyAll();
    // This method is invoked when the list is completed.
    public void listCompleted(PrintObjectListEvent event)
    System.out.println("*****The list has completed*****");
    synchronized (this)
    // Set flag to indicate that the list has
    // completed and wake up foreground thread.
    fListCompleted = true;
    notifyAll();
    // This method is invoked if an error occurs while retrieving
    // the list.
    public void listErrorOccurred(PrintObjectListEvent event)
    System.out.println("*****The list had an error*****");
    fListError = true;
    listException = event.getException();
    synchronized(this)
    // Set flag to indicate that the list has
    // completed and wake up foreground thread.
    fListCompleted = true;
    notifyAll();
    // This method is invoked when the list is opened.
    public void listOpened(PrintObjectListEvent event)
    System.out.println("*****The list was opened*****");
    listObjectCount = 0;
    // This method is invoked when an object is added to the list.
    public void listObjectAdded(PrintObjectListEvent event)
    // every 25 objects we'll wake up the foreground
    // thread to get the latest objects...
    if( (++listObjectCount % 1) == 0 )
    //System.out.println("*****1 more objects added to the list*****");
    synchronized (this)
    // wake up foreground thread
    notifyAll();
    }

    Hi,
    You could try posting with the code tags (http://forum.java.sun.com/faq.jsp#format). Few people are prepared to read that much code without pretty formatting.
    Check out this forum aswell, it is dedicated to JT400: http://www-912.ibm.com/j_dir/JTOpen.nsf/By+Date?OpenView

  • Maximum number of concurrent connections using java sockets

    How can we find out the maximum number of concurrent connections that can be handled by a pooled connection server?
    I have a pooled server which creates a predefined number of handlers. Upon receiving a new request it accepts the connection and sends it to one of the handler.
    The solution works well for low number of concurrent connections - < 50 or 100
    But as the number increases there seems to be an issue
    1. Ignoring request even if i increase the handlers
    2. Increase in delay. [I feel that the listening thread is not getting the time slice to go read the socket for new requests]
    Any idea as to how i can solve this?
    Would an NIO socket help [am using the conventional java.io Serversocket, because my clients may not be non-blocking]??
    Any help would be appreciated.
    Anp

    There is no set maximum, but it is in the thousands on most platforms. I have a production server that handles tens of thousands of connections simultaneously. Most likely you have a bug in your code.

  • Making RPC connection using JAVA

    1-I have a C++ component which understands RPC only , so how to create a JAVA middleware component which establishes the connection with C++ component using RPC .
    how can we take adv of Webservices in java
    2- I need to convert java object to a XML file and pass on to the socket to forward this to 3rd party server (Encoding)
    3 - How i read the XML message response from the third party server and convert it to java object (Decoding)

    Is that the only way? I'm using Metrowerks CodeWarrior as my Java IDE, is there a way other than VJ++ to convert a .JAR file to .DLL?

  • Detect loss of socket connection using java.nio.channels.Selector

    I'm using the nio package to write a "proxy" type application, so I have a ServerSocketChannel listening for incoming connections from a client and then create a SocketChannel to connect to a server. Both SocketChannels are registered to the same Selector for OP_READ requests.
    All works fine, until either the client or server drops the connection. How can I detect this has happened, so my proxy app can drop the other end of the connection ?
    The Selector.select() method is not triggered by this event. I have tried using Selector.select(timeout) and then checking the status of each channel, but they still show isConnected()=true.
    Thanks,
    Phil Blake

    Please don't cross post.
    http://forum.java.sun.com/thread.jsp?thread=184411&forum=4&message=587874

  • How to create database connection and how to call it using Java

    Hi,
    Good day! I'd like to know how I can create a db connection in JDev, then use this connection to retrieve data using a Java Class? I've seen using New Gallery > Database Connection. But I'm not sure how I can access this connection using Java and display some output from the retrieved records.
    Any steps/tutorial link is appreciated.
    Thanks in advance,
    Rian

    Hi,
    If you need to access the connection in the entity object then refer http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcadvgen.htm#BABEIFAI i.e in MODEL.
    But if you want to access connection in ViewController part of application then you need to do it manually.For this i am giving you my code for reference.------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import javax.faces.context.FacesContext;
    import oracle.jdbc.pool.OracleDataSource;
    public class DataHandler {
    String jdbcUrl = null;
    String userid = null;
    String password = null;
    Connection conn;
    public static final String CONNECTION_STRING =
    FacesContext.getCurrentInstance().getExternalContext().getInitParameter("connectionString");
    public static final String USER_NAME =
    FacesContext.getCurrentInstance().getExternalContext().getInitParameter("userName");
    public static final String PASSWORD =
    FacesContext.getCurrentInstance().getExternalContext().getInitParameter("password");
    public DataHandler(String jdbcUrl, String userid, String password,
    boolean shouldConnect) throws SQLException {
    this.jdbcUrl = jdbcUrl;
    this.userid = userid;
    this.password = password;
    if (shouldConnect) {
    connect();
    public void connect() throws SQLException {
    OracleDataSource ds;
    ds = new OracleDataSource();
    ds.setURL(jdbcUrl);
    conn = ds.getConnection(userid, password);
    public Connection getConnection() {
    return conn;
    public ResultSet executeQuery(String sql) throws SQLException {
    Statement s = conn.createStatement();
    return s.executeQuery(sql);
    public void closeConnection() throws SQLException {
    if (!conn.isClosed()) {
    conn.close();
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  • Problem JDBC Connection using OCI Driver on Weblogic Portal on Linux

    Hi Team,
    I want a JDBC connection using OCI Driver in Weblogic Portal 8.1 sp4 on Linux. When I had tested using JDBC connection using Plain Java Code it is working. Also when I create the OCI Connection Weblogic Connection Pool it is working.
    But My Requirement is to create the connection using Java Code in Portal Application
    But When I create OCI connection in the code it is throwing NO SUITABLE DRIVER Found.
    ---------- Code in Plain Java Code ------------ Same code is used in Weblogic Portal Application --------------------------------
         public static void main(String[] args) throws Exception{
              Class.forName("oracle.jdbc.driver.OracleDriver");
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
              String url="jdbc:oracle:oci8:@TESTDB";
              Properties props = new Properties();
         props.put("user","scott");
         props.put("password","tiger");
              conn=DriverManager.getConnection(url,props);
    When I am using the same code in Weblogic Portal and Deployed on Weblogic Portal Server 8.1 SP4 it is throwing following error.
    -------------- Exception on Server Log --------------------
    java.sql.SQLException: No suitable driver
    at java.sql.DriverManager.getConnection(Ljava.lang.String;Ljava.util.Properties;Ljava.lang.ClassLoader;)Ljava.sql.Connection;(Unknown Source)
    at java.sql.DriverManager.getConnection(Ljava.lang.String;Ljava.util.Properties;)Ljava.sql.Connection;(Unknown Source)
    My Environment is
    LINUX
    Weblogic 8.1 SP4
    Oracle 9i Client on Same Machine
    Oracle 10g Server on Different Machine
    My Environment Variables on the Linux Server also set properly as following
    PATH=/apps/pmaaum/ant/apache-ant-1.6.5/bin:.:/apps/beahomedev/jdk142_05/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/apps/oracle/ora9i/product/9.2.0/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/apps/oracle/ora9i/bin
    LD_LIBRARY_PATH=/usr/lib:/apps/oracle/ora9i/product/9.2.0/lib:/apps/oracle/ora9i/product/9.2.0/lib32:/apps/oracle/ora9i/product/9.2.0/rdbms/lib:/usr/openwin/lib:/apps/oracle/ora9i/product/9.2.0/jdbc/lib
    JAVA_HOME=/apps/beahomedev/jdk142_05
    JDBC_LIB=/apps/oracle/ora9i/product/9.2.0/jdbc/lib
    CLASSPATH=:.:/apps/beahomedev/jdk142_05/lib/rt.jar:/apps/oracle/ora9i/product/9.2.0/jdbc/lib/classes12.jar
    Please help me, Let me know if you required anything.
    Thanks in Advance
    Vishnu
    Edited by: vishnuk on Oct 23, 2009 4:07 AM
    Edited by: vishnuk on Oct 23, 2009 4:10 AM

    Hi Vishnu
    Looks like a classloader issue. BEA class loader is very tricky. Any jar added manually in classpath, will end up loading only those classes. Any imports that we have in any of those classes do not get loaded. Anyhow, coming to your point, add classes12.jar inside your portal web project Web-Inf/lib folder and see if that helps. Usually thats where we put all the JARs for 8.1 SPxx applications. If this still breaks, then remove the jar from web-inf/lib folder and add under your portal app App-Inf/lib folder. First try with app-inf/lib folder having this jar. If not then with web-inf/lib. Basically web-inf is specific to that web app only. If you have a different app having this jdbc code, then put under app-inf/lib folder. Make sure that you remove the classes12.jar that you added in classpath either in env variable or in setdomainenv.cmd file.
    When weblogic uses native OCI Drivers, it refers to jars at this location: ....\beawlp814\weblogic81\server\ext\jdbc\oracle\10g or 9g. Try using one of these jars and see if that works. Most of the times I used these jars only for oracle specific native drivers.
    Word of caution. Try to use Connection Pool and a DataSource created in weblogic console for your jdbc code. This Datasource can still use the Oracle drivers that you want (instead of BEA Weblogic wrapper oci drivers) located in above location. Use JNDI Lookup and get Datasource and then connection. This is more recommended approach with many advantages then using DriverManager approach..
    Goud

  • Polling gpib/enet unit over tcp/ip using java

    I understand that there is a linux driver for the gpib/enet product. Since I assume this device is polled over a tcp/ip connection, do I need to do this in C, ot can I establish a socket connection using java ? If so, what is the driver for ? is it just to assign an ip address and other setup functions ?
    Thanks
    John Adams

    Hi John,
    You do not need to do this in C. In fact you can do it in just about any language. The librarys are exported to a shared object, so as long as your language can make calls to a .so, you are good to go. I am positive that java has this capability.
    Hope this helps out! If you need the driver, it is available at www.ni.com/linux.
    Best Regards,
    Aaron K.
    Application Engineer
    National Instruments

Maybe you are looking for

  • How to use FORMULA in ABAP for calculation

    hi all, i have to do some calculation in my report and because of this reason i want to use formula. Could any body tell me the best way to use of formula for calculation purpose in ABAP or any other way? Thansk, abapfk Moderator Message: You don't n

  • Make x64 default with "open with" menu

         Ive seen several threads to make x32 the default but not to many to make x64 the defualt. It appears that once the install is made I cannot only uninstall the 32 bit photoshop, only both at the same time. I have recently moved from cs4 to cs5. E

  • Plug-in 1.3.1_02  & Plug-in 1.4.0 interop issues

    I have Java Plug-in 1.3.1_02 and Java Plug-in 1.4.0 installed on Win2000 sp2. I have come across a weird problem which shows up when loading html files (with plugin tags specified), compared to web-site access. When I load a plugin 1.3.1 initially, s

  • Where used List for Packages (from Transport connection)

    Hi SDN, If objects , such as queries, or webtemplates, are incorrectly allocated to a BEx package at the beginning, my question is as follows: Can we find out which objects/queries/templates have been allocated to a particular package? Via some table

  • Input field validation in web dynpro abap

    Hi....i have a input field in a view, which is bound with dictionary object of char type ,through context.for this input field, i have to allow the end users to enter the numeric and float values only,but in my condition it accepting everything and r