eng.ali
02-08-2011, 10:50 PM
السلام عليكم ورحمة الله وبركاته
لو سمحتوا يا جماعة انا حاسبات ومعلومات
و مطلوب منى برنامج اول خطوة فيه انى اجيب البيانات اللى البرنامج هيشتغل عليها من الداتابيز
وانا مش عارف ازاى فى الجافا هجيب بيانات من الداتابيز
eng.ahmed55
03-08-2011, 03:41 PM
view
other windows
database explorer
اضغط ع الكونيكشن كليك يمين
add connection
microsoft sql database
browse
وبعدين اختار ملف الداتابيز ودوس
ok
~: Zac :~
03-08-2011, 05:15 PM
لو تقصد انك تعمل كونكشن بالداتابيز ف الجافا ف اعتقد ان الكتاب دا هيساعدك ان شاء الله
http://www.mediafire.com/?epb07ockc6cf64t
ولو فيه جزء محتاج فيه توضيح اتفضل اسال وان شاء الله هحاول اساعدك :)
ahmed abobakr
03-08-2011, 05:51 PM
السلام عليكم
عشان تتعامل مع الداتابيز من الجافا لازم تعمل كونكشن بالداتابيز
ودا بيعتمد على نوع الداتابيز ال انت شغال عليها oracle , mysql, sqlserver
ياريت حضرتك تحدد نوع الداتابيز وان شاء الله هقدر اساعدك
eng.ali
03-08-2011, 08:00 PM
view
other windows
database explorer
اضغط ع الكونيكشن كليك يمين
add connection
microsoft sql database
browse
وبعدين اختار ملف الداتابيز ودوس
ok
شكرا ليك على الرد يابشمهندس هجرب الحل دا
لو تقصد انك تعمل كونكشن بالداتابيز ف الجافا ف اعتقد ان الكتاب دا هيساعدك ان شاء الله
ولو فيه جزء محتاج فيه توضيح اتفضل اسال وان شاء الله هحاول اساعدك :)
شكرا لرد حضرتك وهشوف الكتاب ويارب يساعدنى
السلام عليكم
عشان تتعامل مع الداتابيز من الجافا لازم تعمل كونكشن بالداتابيز
ودا بيعتمد على نوع الداتابيز ال انت شغال عليها oracle , mysql, sqlserver
ياريت حضرتك تحدد نوع الداتابيز وان شاء الله هقدر اساعدك
شكرا لحضرتك يابشمهندس والداتابيز موجودة على microsoft sql server 2005
ahmed abobakr
04-08-2011, 02:37 AM
اوك
دلوقت عشان تجيب بيانات من الداتابيز
دى الخطوات
1- create connection
2- create statement on the current connection
3- create ResultSet to hold the result of executed statement (query)
عشان تعمل الكونكشن انت محتاج تعرف شوية حاجات
1 - نوع ال JDBC driver ال انت هتستخدمه ودا ببساطه بيعمل لودينج للداتابيز وبينفذ عليها ال sql commands
وفى الحالة دى بيبقى اسمه SQLServerDriver
ودا عشان تعرفه محتاج تعمل الخطوة دى
2-
تحمل sqljdbc.jar ودا هتلقيه متوفر على النت
وهتنفذ الخطوة دى فى البداية
right click on project name -> properties -> java build path -> liberaries -> add Jar and browse to locate the jar file
لو معملتش الخطوة دى هيقولك class not found exception
3- عنوان السيرفر ال عليه الداتابيز والبورت بتاعه واسم الداتابيز واليوزرنيم والباس ان وجد
دا الكود
Class for connecting with DB to test it u must change the url parameters
package javaapplication1;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Connect
{
public Connection createConnection()
{
String url;
Connection con = null;
// Class.forName("com.mysql.jdbc.Driver").newInstance();
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
url = "jdbc:sqlserver://AHMED-8A6808913:1433;databaseName=Test;selectMethod=curs or;integrated security=false;Trusted_Connection=no";
try {
con = DriverManager.getConnection(url,"sa","12345");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(con==null)
{
System.err.print("No Connection");
}
try {
if(!con.isClosed())
System.out.println("Successfully connected to " +
"SQL server using TCP/IP...");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return con;
}
}
To test
public class Main {
/**
* *param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Connect con = new Connect();
con.createConnection();
}
result for testing
Successfully connected to SQL server using TCP/IP...
Now DB is Ready for ur query
to execute query you will define statement on the current connection and the write ur query and excecute
this is ex
Connect connection = new Connect();
Statement statement = null;
Connection con = null;
ResultSet resultSet = null; //-------------------> to hold result of query
con = connection.createConnection(); //---------------------->> connection created
// create statement and define the type of result set
statement = con.createStatement(Room_resultSet.TYPE_SCROLL_SEN SITIVE,Room_resultSet.CONCUR_UPDATABLE);
String query = "Select * from table where Class";
//////// excecuteeeeeee
resultSet = statement.executeQuery(query);
after that
you have resulrtset contains data u are looking for
retrieve the data and work
اسف انى دخلت اللغات بس عشان معظم الكلام مينفعش عربى
عموما انا موجود فى اى وقت عشان لو فى حاجة مش واضحة او فى مشاكل اخرى
السلام عليكم
eng.ali
05-08-2011, 05:21 PM
اوك
دلوقت عشان تجيب بيانات من الداتابيز
دى الخطوات
1- create connection
2- create statement on the current connection
3- create resultset to hold the result of executed statement (query)
عشان تعمل الكونكشن انت محتاج تعرف شوية حاجات
1 - نوع ال jdbc driver ال انت هتستخدمه ودا ببساطه بيعمل لودينج للداتابيز وبينفذ عليها ال sql commands
وفى الحالة دى بيبقى اسمه sqlserverdriver
ودا عشان تعرفه محتاج تعمل الخطوة دى
2-
تحمل sqljdbc.jar ودا هتلقيه متوفر على النت
وهتنفذ الخطوة دى فى البداية
right click on project name -> properties -> java build path -> liberaries -> add jar and browse to locate the jar file
لو معملتش الخطوة دى هيقولك class not found exception
3- عنوان السيرفر ال عليه الداتابيز والبورت بتاعه واسم الداتابيز واليوزرنيم والباس ان وجد
دا الكود
class for connecting with db to test it u must change the url parameters
package javaapplication1;
import java.sql.connection;
import java.sql.drivermanager;
import java.sql.sqlexception;
public class connect
{
public connection createconnection()
{
string url;
connection con = null;
// class.forname("com.mysql.jdbc.driver").newinstance();
try {
class.forname("com.microsoft.sqlserver.jdbc.sqlserverdriver");
} catch (classnotfoundexception e1) {
// todo auto-generated catch block
e1.printstacktrace();
}
url = "jdbc:sqlserver://ahmed-8a6808913:1433;databasename=test;selectmethod=curs or;integrated security=false;trusted_connection=no";
try {
con = drivermanager.getconnection(url,"sa","12345");
} catch (sqlexception e) {
// todo auto-generated catch block
e.printstacktrace();
}
if(con==null)
{
system.err.print("no connection");
}
try {
if(!con.isclosed())
system.out.println("successfully connected to " +
"sql server using tcp/ip...");
} catch (sqlexception e) {
// todo auto-generated catch block
e.printstacktrace();
}
return con;
}
}
to test
public class main {
/**
* *param args the command line arguments
*/
public static void main(string[] args) {
// todo code application logic here
connect con = new connect();
con.createconnection();
}
result for testing
successfully connected to sql server using tcp/ip...
now db is ready for ur query
to execute query you will define statement on the current connection and the write ur query and excecute
this is ex
connect connection = new connect();
statement statement = null;
connection con = null;
resultset resultset = null; //-------------------> to hold result of query
con = connection.createconnection(); //---------------------->> connection created
// create statement and define the type of result set
statement = con.createstatement(room_resultset.type_scroll_sen sitive,room_resultset.concur_updatable);
string query = "select * from table where class";
//////// excecuteeeeeee
resultset = statement.executequery(query);
after that
you have resulrtset contains data u are looking for
retrieve the data and work
اسف انى دخلت اللغات بس عشان معظم الكلام مينفعش عربى
عموما انا موجود فى اى وقت عشان لو فى حاجة مش واضحة او فى مشاكل اخرى
السلام عليكم
الف شكر يابشمهندس على المجهود دا والحمدلله اشتغل ومفيش مشاكل
الف شكر لكل الناس اللى حاولوا يساعدونى
بجد منتدى رائع