Solved

source code links

Posted on 2001-06-26
3
191 Views
Last Modified: 2011-09-20
Anyone can give links that give library system sourcode in JAVA.
Or source code of java of any systems that connect to  MS. Access or SQL server database with add, delete, update or search function.
0
Comment
Question by:anwar13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
wgilster earned 100 total points
ID: 6228363
To run my example you will need to create a Data Source Name on your machine called 'AccessTestDSN'.  You can use any Access, SQL database you want, my example uses a table in the database called 'TestTable'.


package classes;
import java.sql.*;

public class TestServer
{
  static
  {
      try  {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      }
      catch (Exception e) {
          System.err.println(e);
      }
  }

  public static void main(String args[]) {
      Connection conn=null;
      Statement stmt=null;
      String sql="";
      try {
          conn=DriverManager.getConnection("jdbc:odbc:AccessTestDSN","","");
          stmt=conn.createStatement();
          sql="INSERT INTO [TestTable] (FIELD_NAME1 FIELD_NAME2 FIELD_NAME3) VALUES (100,'String Value',200)";
          stmt.executeUpdate(sql);

      }
      catch (Exception e){
          System.err.println(e);
      }
      finally {
          try{
              stmt.close();
              conn.close();
              stmt=null;
              conn=null;
          }
          catch(Exception e){}
      }
  }
}
0
 

Author Comment

by:anwar13
ID: 6231547
Thank you....
0
 

Author Comment

by:anwar13
ID: 6238114
wgilster:

package classes;
import java.sql.*;

public class TestServer
{
 static
 {
     try  {
       
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     }
     catch (Exception e) {
         System.err.println(e);
     }
 }

 public static void main(String args[]) {
     Connection conn=null;
     Statement stmt=null;
     String sql="";
     try {
       
conn=DriverManager.getConnection("jdbc:odbc:AccessTestDSN","","");
         stmt=conn.createStatement();
         sql="INSERT INTO [TestTable] (FIELD_NAME1
FIELD_NAME2 FIELD_NAME3) VALUES (100,'String
Value',200)";
         stmt.executeUpdate(sql);

     }
     catch (Exception e){
         System.err.println(e);
     }
     finally {
         try{
             stmt.close();
             conn.close();
             stmt=null;
             conn=null;
         }
         catch(Exception e){}
     }
 }
}


I compiled it without any errors...but when i run it
with
c:\java TestServer.class

the error comes out like:

Exception in thread "main"
java.lang.NoClassDefFoundError: TestServer/class

I am new in JAVA, so does it have to do with JDBC, I
don't know whether i have JDBC or not, i am using
windows2000.

regards,
anwar13
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question