Solved

source code links

Posted on 2001-06-26
3
192 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jdbc error in jsp application 20 85
Bot application - advice 3 79
listing all the respondents to a twitter feed - Java 5 41
Java ArrayList and if statement 2 50
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

739 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