Solved

source code links

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 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:

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now