Jdbc help

Hi all,
When I tried to retrieve values from database like text and integer values ,I can't assign to the text box .Plz can anyone help me.
here is the code
import java.sql.*;
import java.io.PrintStream;
import java.awt.event.*;
import java.awt.*;
import java.applet.*;
public class fr extends Frame implements ActionListener
static Label l1,l2;
static TextField t1,t2;
static Button b1,b2,b3,b4,b5;
static fr f;
static Connection con;
static Statement st;
static ResultSet rs;
String name,add;
public static void main(String args[])
f=new fr();
f.setVisible(true);
f.setSize(500,500);
f.addlab();
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:dbfirst");
st=con.createStatement();
catch(Exception ea)
System.out.println(ea.getMessage());
void addlab()
l1=new Label("Name");
l2=new Label("age");
t1=new TextField(20);
t2=new TextField(20);
b1=new Button("Save");
b2=new Button("Display");
b3=new Button("Delete");
b4=new Button("Update");
b5=new Button("Exit");
setLayout(new FlowLayout(FlowLayout.LEFT,20,20));
add(l1);
add(l2);
add(t1);
add(t2);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b5.addActionListener(this);
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
public void actionPerformed(ActionEvent e)
if(e.getSource()==b1)
String n=t1.getText();
int a=t2.getText();
try
st.executeUpdate("insert into first values('"+n+"','"+a+"')");
catch(Exception ae)
System.out.println(ae.getMessage());
if(e.getSource()==b2)
try
st.executeQuery("select * from first");
while(rs.next())
name=rs.getString("name");
age=rs.getInt("add");
t1.setText(name);//We can't assign int to textbox t2 settext() can be used to set only Strings
t2.setText(add);
catch(Exception e1)
System.out.println("cannot display");
if(e.getSource()==b3)
try
String n=t1.getText();
st.executeUpdate("delete from first where name='"+n+"'");
con.close();
catch(Exception ae)
System.out.println(ae.getMessage());
if(e.getSource()==b5)
System.exit(0);
insert and delete I can do but retrieving values is not possible in my code. plz help me

I tried But it didn't work .Iam new to java plz help
to how to use database in java using swings.Step 1) Please complete the following tutorials in order
http://java.sun.com/docs/books/tutorial/java/index.html
http://java.sun.com/docs/books/tutorial/essential/index.html
http://java.sun.com/docs/books/tutorial/collections/index.html
http://java.sun.com/docs/books/tutorial/jdbc/index.html
http://java.sun.com/docs/books/tutorial/uiswing/index.html
This will take you significantly more than 10 minutes I assure you.
Step 2) Go here http://www.springframework.org/
Upon the successful completion of these steps as described you will be able to answer your own questions young grasshopper.

Similar Messages

  • Can't find "Delegate Class Name" for JDBC Helper Service

    Hi,
    I downloaded WLServer 6.1 with sp1 and WLPortal 4.0, installed them on Solaris 7 using default DB cloudscape -- everything was fine. Now, I'm trying to configure database to Oracle 8.1.7.
    In "Configure the JDBC Helper Service" section of document "Configuring WebLogic Portal for Oracle Databases" (http://e-docs.bea.com/wlp/docs40/deploygd/oraclnew.htm), step 2 requires to enter value of "com.bea.p13n.util.jdbc.internal.OracleJDriverJdbcHelperDelegate" to "Delegate Class Name". But, I can't find this "Delegate Class Name" variable. The available varialbles on the Configuration tab on my screen are: Maximum Number of Retries, Maximum Wait Time (milliseconds), Use CLOBs for Read?, Use CLOBs for Write?. And the Configuration tab is the only available tag for JDBC Helper Service. Did I download a different version from other people? I downloaded it within 3 months.
    Can anyone help?
    Thanks in advance,
    Jane

    Thanks Steve.
    I had my own jndi.properties file that's why it was working with ejb bean I created in the AM and not with the sdo web service.
    I didn't know I had to add the jndi properties to the connection.xml maybe you can update the documentation.
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <ns2:References xmlns:ns2="http://xmlns.oracle.com/adf/jndi">
    <Reference className="oracle.jbo.client.svc.Service"
    name="{/test/model/common/}DepartmentModuleService">
    <Factory className="oracle.jbo.client.svc.ServiceFactory"/>
    <RefAddresses>
    <StringRefAddr addrType="serviceInterfaceName">
    <Contents>test.model.common.serviceinterface.DepartmentModuleService</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="serviceEndpointProvider">
    <Contents>ADFBC</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiName">
    <Contents>test.model.common.DepartmentModuleServiceBean</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="serviceSchemaName">
    <Contents>DepartmentModuleService.xsd</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="serviceSchemaLocation">
    <Contents>test/model/common/serviceinterface/</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiFactoryInitial">
    <Contents>oracle.j2ee.rmi.RMIInitialContextFactory</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiProviderURL">
    <Contents>ormi://localhost:23791/SvcInterfaceDeploy_MiddleTier</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiSecurityPrincipal">
    <Contents>fmwadmin</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="jndiSecurityCredentials">
    <Contents>welcome</Contents>
    </StringRefAddr>
    <StringRefAddr addrType="serviceSchemaName">
    <Contents>HRAppService.xsd</Contents>
    </StringRefAddr>
    </RefAddresses>
    </Reference>
    </ns2:References>
    thanks edwin

  • JDBC Helper Service

    Hello,
    The SQL Server DB Configuration in WLP Deployment Guide says JDBC Helper
    Service needs to be configured for each application deployed. Do I need to
    do this for other applications that has been installed and deployed
    out-of-box (p13nApp, p13nConsoleApp, paymentWSApp, taxWSApp, wlcsApp,
    wlpDocsApp)? I only did it for portal app so far and just got me wondered...
    Thank you,
    Makoto

    Makoto Suzuki wrote:
    Hi,
    So am I correct in thinking that the other apps are still using cloudscape
    database, although the connection pools and data sources now point to SQL
    Server after configuration is changed?I don't mean that. Those apps won't work. So, if you plan to use all the
    apps, make this change in all the apps.
    Subbu
    >
    Thank you,
    Makoto
    "Subbu Allamaraju" <subbuATBeaDOTCom> wrote in message
    news:3d08a832$[email protected]..
    Makoto,
    You need not, if you're not using those apps.
    Subbu
    Makoto Suzuki wrote:
    Hello,
    The SQL Server DB Configuration in WLP Deployment Guide says JDBC Helper
    Service needs to be configured for each application deployed. Do I need
    to
    do this for other applications that has been installed and deployed
    out-of-box (p13nApp, p13nConsoleApp, paymentWSApp, taxWSApp, wlcsApp,
    wlpDocsApp)? I only did it for portal app so far and just got mewondered...
    Thank you,
    Makoto

  • Sender JDBC: help to construct Update statement

    Hi,
    I need help in writing a update statement to DB2 database in sender JDBC adapter.
    The sender adapter picks up only few records say 10 at a time which match the Select query condition. So I would need to update only those selected "n" records and not all the records that match the Select query condition.
    Select looks like :
    Select * from <table> where <condition> fetch first <n> rows only.
    But it is not allowing the following update
    update <table> set <field> = <value> where <field> IN (Select * from <table> where <condition> fetch first <n> rows only)
    The above statement errors because DB2 does not allows u201CFetchu201D statement within the update sub query.
    Any pointers to a write update statement for n records is highly appreciatedu2026
    ~SaNvu2026

    Hi Santosh,
    In JDBC Sender Adapter provide the following select & update statements
    Select Statement:
    select * from <table> where <condition> AND ROWNUM<N (N==No.of Rows)
    Update Statement:
    update <table> set <field> = <value> where <field> IN (Select * from <table> where <condition> AND ROWNUM<N)
    (N==No.of Rows)
    And for the error you are facing is because of the server communication link failure between the two systems.
    Check the connections and try to stop & start communication channels once.
    Regards
    Venkat Rao .G

  • Connecting to SQL Using JDBC - Help!

    Hi All
    I am looking to create some conections to various custom SQL DBs so that I can produce reports and queries using visual composer. I have various Stored procedures DTS and tables I need to access.
    I have no idea where to start with this, only that I need to use JDBC. Does anyone have or can point me in the right direction on how to set up these systems in the portal. I have EP7.0 SP8.
    Many thanks for your help and time
    Phil

    Hi Phil,
    you can find a good example on:
    https://www.sdn.sap.com/irj/sdn/visualcomposer?rid=/library/uuid/16244247-0a01-0010-3294-d81c21e7e86e
    With JDBC Systems you can call stores procedures and with BI JDBC Systems you can see the tables and views.
    You can create a standar JDBC using the portal Wizard and the BI JDBC systems with:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/6209b52e-0401-0010-6a9f-d40ec3a09424
    Best Regards.
    Nacho

  • MS SQL Server jdbc help

    I am trying to connect to a MS SQL Server 2000 db from my linux Mandrake10 box using SQuirreL. I have downloaded a tar file from MS's website, which I have untarred to produce 3 jar files: msbase.jar, mssqlserver.jar and msutil.jar.
    According to the MS jdbc page, the jdbc driver is in the mssqlserver.jar file, but the only driver that I can find in any of these three jar files is the "com.microsoft.jdbc.base.BaseDriver" driver in the msbase.jar file. The driver I am looking for (or rather that I think I should be looking for) is the "com.microsoft.jdbc.sqlserver.SQLServerDriver" driver, which I can't find in any of the three jars.
    HELP!! Am I using the correct jar/driver/etc ? Or is SQuirreL just being stubborn in picking up the available drivers from the jar files...?
    Thx

    Either look into the documentation of SQuirreL SQL for how to specify all 3 jars as classpath for the MS driver (you'll need all of them, because there are dependencies between them) or get jTDS or a commercial driver.
    Alin.

  • JDBC-help,thank (web service 6.1)

    I'm try the example(Sun\WebServer6.1 plugins\java\samples\webapps\jdbc\simple). I encounter some trouble.
    Here is my configure.
    sun-web.xml:
    <resource-ref>
    <res-ref-name>jdbc/jdbc-simple</res-ref-name>
    <jndi-name>jdbc/jdbc-simple</jndi-name>
    </resource-ref>
    web.xml:
    <resource-ref>
    <description></description>
    <res-ref-name>jdbc/jdbc-simple</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    server.xml:
    <JAVA javahome="f:/Sun/WebServer6.1/bin/https/jdk" serverclasspath="f:/Sun/WebServer6.1/bin/https/jar/webserv-rt.jar;${java.home}/lib/tools.jar;f:/Sun/WebServer6.1/bin/https/jar/webserv-ext.jar;f:/Sun/WebServer6.1/bin/https/jar/webserv-jstl.jar;f:/Sun/WebServer6.1/bin/https/jar/ktsearch.jar;f:/Sun/WebServer6.1/bin/https/jar/class12.jar" classpathsuffix="f:/Sun/WebServer6.1/bin/https/jar/class12.jar" envclasspathignored="on" debug="false" debugoptions="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n" dynamicreloadinterval="-1">
    <RESOURCES>
    <JDBCCONNECTIONPOOL name="jdbc-simple-pool" datasourceclassname="oracle.jdbc.pool.OracleDataSource" steadypoolsize="8" maxpoolsize="32" poolresizequantity="2" idletimeout="300" maxwaittime="60000" connectionvalidationrequired="off" connectionvalidationmethod="auto-commit" validationtablename="" failallconnections="off" transactionisolationlevel="read-uncommitted" isolationlevelguaranteed="off">
    <PROPERTY name="URL" value="jdbc:oracle:thin:@127.0.0.1:1521:myora"/>
    <PROPERTY name="User" value="wyxxk"/>
    <PROPERTY name="Password" value="111"/>
    </JDBCCONNECTIONPOOL>
    <JDBCRESOURCE jndiname="jdbc/jdbc-simple" poolname="jdbc-simple-pool" enabled="on"/>
    </RESOURCES>
    First ,it report Cannot create resource instance.
    Now ,it report ClassNotFoundException.
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr: java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleDataSource
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at java.security.AccessController.doPrivileged(Native Method)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at com.sun.enterprise.util.Utility.loadClass(Utility.java:385)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at com.sun.enterprise.repository.JdbcConnectionPool.createDataSource(JdbcConnectionPool.java:231)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at com.sun.enterprise.resource.JdbcAllocator.<init>(JdbcAllocator.java:55)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at com.sun.enterprise.resource.JdbcDataSource.getAllocator(JdbcDataSource.java:234)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at com.sun.enterprise.resource.JdbcDataSource.internalGetConnection(JdbcDataSource.java:200)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at com.sun.enterprise.resource.JdbcDataSource.getConnection(JdbcDataSource.java:132)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at db.dbconn.DBConn(dbconn.java:30)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at login.LoginAction.isRegisterLogin(LoginAction.java:56)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at login.LoginAction.perform(LoginAction.java:176)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1787)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
    [12/Jun/2006:17:45:57] warning ( 340): CORE3283: stderr:      at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
    [12/Jun/2006:17:45:57] failure ( 340): for host 192.168.1.116 trying to POST /test/loginAction.do, service-j2ee reports: RSR0032: Got Unexpected Exception in getConnection [{0}]
    com.sun.enterprise.repository.J2EEResourceException
    java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleDataSource
         at com.sun.enterprise.repository.JdbcConnectionPool.createDataSource(JdbcConnectionPool.java:242)
         at com.sun.enterprise.resource.JdbcAllocator.<init>(JdbcAllocator.java:55)
         at com.sun.enterprise.resource.JdbcDataSource.getAllocator(JdbcDataSource.java:234)
         at com.sun.enterprise.resource.JdbcDataSource.internalGetConnection(JdbcDataSource.java:200)
         at com.sun.enterprise.resource.JdbcDataSource.getConnection(JdbcDataSource.java:132)
         at db.dbconn.DBConn(dbconn.java:30)
         at login.LoginAction.isRegisterLogin(LoginAction.java:56)
         at login.LoginAction.perform(LoginAction.java:176)
         at org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1787)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:807)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
         at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
         at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
         at com.iplanet.ias.web.WebContainer.service(WebContainer.java:586)
    I have seen the simliar page in the form,but i can't find the solution.
    Anyone can help me,Thank

    It seems that the server cannot find the JDBC driver. I see from you classpath suffix that you have indicated where it is. The jar file name though, looks a bit suspicious.
    class12.jar
    Should not it be classes12.jar?

  • [b]JDBC help needed[/b]

    Hello,
    I'm using Win2000 SP4 and J2SDK1.4.2_05 and I'm trying to connect to a remote server where Oracle9i ver. 9.2.0.1.0 is installed.
    I have simply downloaded ojdbc14.jar into [Java_HOME]\jre\lib\exp\ directory, without setting a CLASSPATH
    I've written this code:
    import java.sql.*;
    import oracle.jdbc.driver.*;
    class JDBCVersion
    public static void main (String args[])
    throws SQLException
    DriverManager.registerDriver
    (new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@HOST:1521:SID","user","passw");
    DatabaseMetaData meta = conn.getMetaData();
    System.out.println("JDBC driver version is " + meta.getDriverVersion());
    When I'm trying to compile everything is O.K.:
    c:\>javac JDBCVersion.java
    but when I'm trying to run it I get an error:
    c:\>java JDBCVersion
    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver at JDBCVersion.main(JDBCVersion.java:10)
    And as soon as I set a CLASSPATH I'm getting this:
    c:\>java JDBCVersion
    Exception in thread "main" java.lang.NoClassDefFoundError: JDBCVersion
    Watta hell I'm doing wrong?
    Please someone HELP me, cause I'm losing my mind already.
    THANKS.

    I solved this problem myself
    No need to set any CLASSPATH
    just when run java program need to write
    java -cp .;[ORACLE_HOME]\jdbc\lib\ojdbc14.jar program_name

  • JDBC Help - java.lang.ClassNotFoundException

    This has been one of the greatest headaches I've had since I started programming 10+ years ago. I've just started learning Java, and I really need to connect to a JDBC database (Sybase). Please, help me!!
    I've stripped my code down, because this is the part that's causing the code to generate the error:
    import java.sql.*;
    import java.io.File;
    public class test {
         public static void main() {
              Class.forName("ianywhere.ml.jdbcodbc.IDriver");
    }The error message is:
    test.java:6: unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown
         Class.forName("ianywhere.ml.jdbcodbc.IDriver");
              ^I'm using the following JDBC driver:
    http://astronomicus.net/jodbc.jar
    I'm typing this in to compile the code:
    javac -classpath "%ASANY9%\java\jodbc.jar" test.javaAnd finally, my CLASSPATH is:
    .;C:\j2sdk1.4.1_07\bin;%ASANY9%\java\
    The driver is located in the "%ASANY9%\java\" directory.
    Thank you so much for your help!!!
    Message was edited by:
    tate_etc
    Message was edited by:
    tate_etc

    Pu the statement in a try catch block.

  • JDBC help needed

    hi
    i am connecting sql using jdbc...and i want to find the exact width of columns in a table.....e.g if a column with type datatime has width 8.........then using getPrecision() and getScale method() it do not return the exact width but it returns (23,3).....can anybody help me in finding exact width of a column
    i shall be thankful
    regards
    muddsar

    let me clear ur confusion.......when u open table in sql server 2000 in design view....it shows u the column length that is allowed......i just want to get that length......actually i m getting exceptionlike this...
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Column or parameter #3: Cannot specify a column width
    this error appear for datatype like smallint,int......i have also tried to manually create table using sql server query analyzer but it also gave same error if i try to specify column width for smallint or int.
    now whats ur opinion

  • JDBC help needed ; java.lang.NoClassDefFoundError:test1

    hi, everyone, i had a problem when i run my own app to connect javadb in embedded mode
    i ve added the ~/javadb/lib/derby.jar to CLASSPATH
    and ~/javadb/lib/derby.jar:~/javadb/lib/derbytools.jar to DERBY_HOME
    but there is a problem said my own application class cannot be found.
    here is my code:
    import java.sql.*;
    class test1
      public static void main (String args [])
           throws SQLException
           try {
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
        } catch (Exception e) {
            System.out.println("ERROR: failed to load javadb JDBC driver.");
            e.printStackTrace();
            return;
          Connection conn = DriverManager.getConnection("jdbc:derby:testdb");
      try{
         Statement stmt1 = conn.createStatement();
            ResultSet rset1 = stmt1.executeQuery( "SELECT * FROM PART" );
         long counter1 = 0;
            double price1;
         while ( rset1.next() )
             price1 = rset1.getDouble(8);
             if (price1 == 1306.4)
              counter1++;
         System.out.println( counter1 );
         stmt1.executeQuery("SHUTDOWN");
         conn.close();
       catch (SQLException e )
         String errmsg = e.getMessage();
         System.out.println( errmsg );
    }and i ve followed one Derby JDBC tutorial on the internet,
    * AutoLoadJdbcDriver.java
    * Copyright (c) 2007 by Dr. Herong Yang. All rights reserved.
    import java.sql.*;
    import java.util.*;
    public class AutoLoadJdbcDriver {
      public static void main(String [] args) {
        Connection con = null;
        try {
          listDrivers();
    // Find the driver for a given URL
          Driver driverClass = (Driver) DriverManager.getDriver(
            "jdbc:derby://somehost/somedb");
          System.out.println("\nDriver for jdbc:derby://somehost/somedb");
          System.out.println("   "+driverClass.getClass().getName());
          listDrivers();
        } catch (Exception e) {
          System.err.println("Exception: "+e.getMessage());
      private static void listDrivers() {
        Enumeration driverList = DriverManager.getDrivers();
        System.out.println("\nList of drivers:");
        while (driverList.hasMoreElements()) {
          Driver driverClass = (Driver) driverList.nextElement();
          System.out.println("   "+driverClass.getClass().getName());
    The output below confirms that the DriverManager class is able to load any JDBC driver classes as long as their JAR files are included in the classpath.
    C:\>javac AutoLoadJdbcDriver.java
    C:\>java -cp .;\local\javadb\lib\derbyclient.jar AutoLoadJdbcDriver
    List of drivers:
    sun.jdbc.odbc.JdbcOdbcDriver
    org.apache.derby.jdbc.ClientDriver
    Driver for jdbc:derby://somehost/somedb
    org.apache.derby.jdbc.ClientDriver
    List of drivers:
    sun.jdbc.odbc.JdbcOdbcDriver
    org.apache.derby.jdbc.ClientDriver
    but on my machine , it keep telling me the massage
    Exception in thread "main" java.lang.NoClassDefFoundError: SimpleApp
    Exception in thread "main" java.lang.NoClassDefFoundError: test1
    Exception in thread "main" java.lang.NoClassDefFoundError: AutoLoadJdbcDriver
    the ij works well
    and the other java app(without jdbc) works well.
    anybody can help me to solve this problem?
    Edited by: Xiao on Jan 18, 2008 6:19 PM

    but on my machine , it keep telling me the massage
    Exception in thread "main" java.lang.NoClassDefFoundError: SimpleApp
    Exception in thread "main" java.lang.NoClassDefFoundError: test1
    Exception in thread "main" java.lang.NoClassDefFoundError: AutoLoadJdbcDriverI assume you get these messages when you try and run the three programs mentioned (SimpleApp, test1 and AutoLoadJdbcDriver).
    What commands do you use to do this? What does the command line report the CLASSPATH to be (using the echo command)?
    The simplest cause would be that you have the derby jar mentioned as part of CLASSPATH, but not the current directory.

  • Driver not found - JDBC - HELP PLZ!

    Hello everyone.
    i am trying to access my database and this is the code i made:
    public static void connectToDataBase()
    Connection connect = null;
    try{
    String driverName = "oracle.jdbc.driver.OracleDriver";
    String serverName = "192.168.5.6";
    String portNumber = "1521";
    String sid = "deve";
    String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber +
    ":" + sid;
    String usr = "emma";
    String pwd = "emma";
    //Load the JDBC driver
    Class.forName(driverName);
    //Connect to the base
    connect = DriverManager.getConnection(url,usr,pwd);
    catch(ClassNotFoundException e){
    System.out.println("Error---No database driver");
    catch(SQLException s){
    System.out.println("Error---No connection to the database");
    However, when i execute this program, a ClassNotFoundException is launched because i get the message "Error---No database driver".
    Can anyone help me please??
    thank you

    However, when i execute this program, a
    ClassNotFoundException is launched because i get the
    message "Error---No database driver".As mentioned already, you need to add the driver jar in the classpath. Depending on the type of application you are creating, the method for doing that would vary.
    For a simple standalone application, it can be achieved by simply including the JAR name (with path) in the classpath. This can be done by editing the CLASSPATH variable, which I mostly do not prefer, or using the command line switch -cp to set the classpath for the specific command.
    If you are dealing with web applications, you need not play around with the environment variables simply because it would not have any effect. Almost all application servers AFAIK ignore the environment settings. The best way of doing it is copying the driver jar to the WEB-INF/lib sub-directory under your webapp directory. (You could ignore this advice ATM if you haven't started with web applications yet). However, the preferred method of connection in case of webapps (or J2EE applications I might generalize) is using a datasource.
    Finally, a word of advice which I am often tempted to mention early on. Ensure that you are closing all the connections, statements and resultsets in your application once their job is done. Not doing so may lead to further complications in the future, depending on the driver implementations. The safest way is to call the close methods on all the JDBC resources in the finally block of your code to ensure that you always close the resources.
    Gluck!

  • MS Access and Java JDBC help!

    Hello, I having trouble with a java GUI.
    I have a MS Access named Database.mdb with a table named Customer which I want my GUI to access.
    I want my GUI to be able to flick through the records using the field I have made for them.
    I already have connected the database using windows xp's "System DSN" and have no problem creating tables using sql statements in my code
    Who can help me? any information would be great.
    Thanks

    I'm doing an inventory software application too...but my application is an automatic software inventory, is automatic your application??
    My result is the software that are intalled in a machine..is your project too?
    Sorry, my english is not very good...

  • Error when run Application with jdbc  Help me please

    this my code:
    public void resultado() {
    String ClassName = "oracle.jdbc.driver.OracleDriver";
    String url = "jdbc:oracle:thin:@educacion04:1521:ora92";
    Connection con;
    Statement stmt;
    try {
    Class.forName(ClassName);
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    try {
    con = DriverManager.getConnection(url,"ora1", "oracle");
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet uprs = stmt.executeQuery("SELECT * FROM ANEXO ");
    uprs.moveToInsertRow();
    uprs.updateString("cod_ane", "uno");
    uprs.updateString("cod_informe", "dos");
    uprs.updateString("", "tres");
    uprs.insertRow();
    uprs.updateString("cod_ane", "cuatro");
    uprs.updateString("cod_informe", "cinco");
    uprs.updateString("desc_anexo", "seis");
    uprs.insertRow();
    uprs.beforeFirst();
    System.out.println("Table ANEXO after insertion:");
    while (uprs.next()) {
    String name = uprs.getString("cod_ane");
    String id = uprs.getString("cod_informe");
    String price = uprs.getString("desc_anexo");
    System.out.print(name + " " + id + " " + price);
    uprs.close();
    stmt.close();
    con.close();
    con.commit();
    } catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    WHEN CALL FUNCTION?????
    send this:
    ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    SQLException: No suitable driver

    Are you sure Oracle driver (classes12.jar or classes12.zip) is in your classpath ???

  • Need JDBC help

    I am connecting to an Oracle database and running a query which returns 1 cell. The content of that cell is numeric with an underscore (Ex.: 13985981261305_840)
    I then want to assign the result of my query to a variable and return it. Please see what am i doing wrong here?
    String oct_session = "";
    try {
         Connection con = null;
         Class.forName("oracle.jdbc.driver.OracleDriver");
         con = DriverManager.getConnection(url, schema, pwd);
         Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
         ResultSet srs = stmt.executeQuery(qry);
         while (srs.next()) {
           oct_session = srs.getCharacterStream("OCT_SESSION").toString();
         srs.close();
         con.close();
         catch (SQLException e) {
              e.printStackTrace();
         catch (ClassNotFoundException e) {
              e.printStackTrace();
    return oct_session;

    Most likely explanation is that you are not running the query that you think you are.
    Other possibility is that you are making an assumption which is not true. Following are SOME possibilities
    - The code above just isn't running
    - The code that is running is not the code that you think it is
    - You are not connecting to the correct database.
    - You are examing the result in some way that modifies/alters the correct value being returned.

Maybe you are looking for

  • Can't select headers in Word for Mac.

    I'm using Word on all of my Macs due to submission requirements of my graduate program, and a document I'm creating has suddenly made headers unselectable.  Posts from 2011 suggest checking Make Master Objects Selectable from the Format menu, but no

  • Random-non-apple-question     ADOBE LIGHT ROOM?

    ...a random question for anyone that uses adobe light room... when i go to import cannon raw files it imports as colour and then after they 'render preview' they turn black and white... i's so fustrating! no presets are on and i reset the settings...

  • Installation oracle client 10g fails

    Hi, I am installing the oracle client 10g in a machine with windows 2000 server advanced with SP4. At the end of the installacion, this when in 99 %, he(she) returns this mistake to me "abnormal program termination" and "updating registry key". Someo

  • Extremely slow internet (WRT150N)

    Hi. I just recently purchased a WRT150N Wireless Router for my household and a WMP300N Wireless Network Controller. Both are 802.11n compatible from my understanding. The other 2 computers in my household are both on G ethernet cards, which most like

  • Pam_ldap login dont work

    I did read almost topics about the subject but i cant see a solution for the problem. I'm running DS 6.2, solaris 10 latest update for server and client, but my client fail when try log in. * The proxyagent its ok. * getent passwd shows my users. * '