اخواني انا في امس الحاجه لمساعدتكم السريعه جدا
انا مبتدى بالجافا لكن اريد معرفة الربط بين قاعدة البيانات واحد البرامج
هذا البرنامج لقاعدة البيانات
import java.sql.*;
import java.util.*;
import java.lang.*;
import javax.swing.*;
public class ReadingDB
{
public static void main( String args[] )
{
try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch (ClassNotFoundException e)
{System.out.println("JDBC Driver NOT known or not FOUND" + e.getMessage());} // + e.ClassNotFoundException()
String url = "jdbc:odbc:db1";
try { Connection conn = DriverManager.getConnection(url);
ResultSet Results;
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
String Query = "Select * from table_1";
Results = stmt.executeQuery(Query);
ResultSetMetaData rsmd;
rsmd = Results.getMetaData();
int Col_Count = rsmd.getColumnCount();
/*
Results.absolute(2);
if (Results.getString(2)!= null)
{
System.out.println("هذا السجل غير فارغ");
}
else
{
System.out.println("فـــــــارغ");
}
*/
String n = JOptionPane.showInputDialog(null,"Enter The Recored Number .. ");
int nn = Integer.parseInt(n);
int i = 0;
Results.beforeFirst();
while (Results.next())
{
i++;
int id = Results.getInt(1);
String name = Results.getString(2);
int phone = Results.getInt(3);
//System.out.println(id+name+phone);
//System.out.println(i);
if (i==nn)
{
String id1 = JOptionPane.showInputDialog(null,"Enter ID .. ");
String name1 = JOptionPane.showInputDialog(null,"Enter Name ..");
String phone1 = JOptionPane.showInputDialog(null,"Enter Phone Number ..");
stmt.addBatch("Insert Into table_2 (id,name,phone) select '"+id1+"','"+name1+"','"+phone1+"'");
}
else
{
stmt.addBatch("Insert Into table_2 (id,name,phone) select '"+id+"','"+name+"','"+phone+"'");
}
}
int []a = stmt.executeBatch();
stmt.close();
stmt=null;
conn.close();
conn=null;
}
catch (SQLException a)
{System.out.println("My Message : Exception not handled " + a.getMessage() + "\n\r" + a.getSQLState());}
System.exit(0);
}
}وهنا احد البرامج التي اريد الربط معه
import java.io.*;
public class ReadTextFileToken2
{
public static void main( String args[]) throws IOException
{
String fileName = "e:/bct.txt";
FileReader fr = new FileReader (fileName);
BufferedReader in = new BufferedReader(fr);
StreamTokenizer reader = new StreamTokenizer(in);
reader.nextToken();
// String ww = "1234";
while (reader.ttype != StreamTokenizer.TT_EOF)
{
if (reader.ttype == StreamTokenizer.TT_WORD)
{
String word = reader.sval;
System.out.println(word);
}
else if (reader.ttype == StreamTokenizer.TT_NUMBER)
{
double numb = reader.nval;
System.out.println(numb);
}
reader.nextToken();
}
in.close();
}
}او هذا البرنامج
import java.io.*;
public class WriteTextFile
{
public static void main( String args[]) throws IOException
{
String fileName = "e:/bct2.txt";
FileWriter fw = new FileWriter (fileName);
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter print = new PrintWriter(bw);
String line = "The course Java 3 in the college of Buraydah123456 ";
print.println(line);
print.println("is a hard course");
print.println("you can have a good mark if you work hard...");
print.close();
}
}ارجو المساعده عاجلاااااااااااا