Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

source code links

Posted on 2001-06-26
3
Medium Priority
?
196 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
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
wgilster earned 400 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

971 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