الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

سؤال في ربط سيرفلت مع قاعده البيانات

مغلق
بدأه مداومه الزياره في 17 ديسمبر 2007 · 5 رد · 1,394 مشاهدة · في JavaEE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

الله يجزاكم خير عندي سؤال

ما أسوي execute

لل ملف الي عني في دوس يطلع لي هذا الغلط

error with connection: java.sql.SQLException:No data found

على أني حاطه الداتا بيس حقتي في نفس ملف الجافا

#2

وضح سؤالك أخي

#3

السلام عليكم

أسفه يا مبتدئ على عدم التوضيح

بس كان قصدي ربط الجافا بالDB

هذا هوا البرنامج

----------------------------------------------------------------

import java.sql.*;

/** A JDBC example that connects to the MicroSoft Access sample
 *  Northwind database, issues a simple SQL query to the
 *  employee table, and prints the results.
 *  <P>
 *  Taken from Core Servlets and JavaServer Pages 2nd Edition
 *  from Prentice Hall and Sun Microsystems Press,
 *  http://www.coreservlets.com/.
 *  © 2003 Marty Hall and Larry Brown.
 *  May be freely used or adapted. 
 */

public class NorthwindTest {
  public static void main(String[] args) {
	String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
	String url = "jdbc:odbc:db4";
	String username = ""; // No username/password required
	String password = ""; // for desktop access to MS Access.
	showEmployeeTable(driver, url, username, password);
  }

  /** Query the employee table and print the first and
   *  last names.
   */

  public static void showEmployeeTable(String driver,
									   String url,
									   String username,
									   String password) {
	try {
	  // Load database driver if it's not already loaded.
	  Class.forName(driver);
	  // Establish network connection to database.
	  Connection connection =
		DriverManager.getConnection(url, username, password);
	  System.out.println("Employees\n" + "==========");
	  // Create a statement for executing queries.
	  Statement statement = connection.createStatement();
	  String query =
		"SELECT number,name, age FROM girl";
	  // Send query to database and store results.
	  ResultSet resultSet = statement.executeQuery(query);
	  // Print results.
	  while(resultSet.next()) {
		System.out.print(resultSet.getString("firstname") + " ");
		System.out.println(resultSet.getString("lastname"));
	  }
	  connection.close();
	} catch(ClassNotFoundException cnfe) {
	  System.err.println("Error loading driver: " + cnfe);
	} catch(SQLException sqle) {
	  System.err.println("Error with connection: " + sqle);
	}
  }
}

لما أسويهما أسوي execute

في دوس يطلع لي هذا الغلط

error with connection: java.sql.SQLException:No data found

ما هو السبب؟؟؟؟

#4

إنتا متأكد إن ال northwind متثبته عندك في الاكسس ؟؟

و إنتا بالفعل سطبتلها DNS ؟؟؟

بص ضيف :

	  sqle.printStackTrace();

في ال handler بتاع ال SQLException وشوف إيه الخطأ بالظبط

#5

السلام عليكم

أنا سويت داتا بيس من عندي و غيرت أسم db في url بأسم data base حقتي

String url = "jdbc:odbc:db4";

وغيرت في statment على حسب الموجود عندي

String query =
		"SELECT number,name, age FROM girl";

هل الي عملته صح و لا لاء ؟؟؟

يعني أنا ما أعتمت على Northwind داتا بيس الموجوده في Microsoft access

و سويت configuringللداتا بيس حقتي بالطريقه الي قلتها

على فكره أنا أستخدم 2007 version من microsoft access

علشان كذا أخترت الدريفر

microsoft access Driver (*.mdb, *.accdb)i

هل الي سويته صح على و لا لأءء ؟؟

#6

الحل بسيط

روحي على Control Panelتبع الويندوز

و بعدين روحي لل Administrative Tools

و بعدين روحي لل Data Sources (ODBC)

اضغطي add

ثم اختاري MicroSoft Access Driver(mdb.*)

ثم اضغطي select

و اختاري المسار الذي موجود فيه ملف ال Access

ثم OK

و انتهى الامر

mofeedchaar@hotmail.com

هذا الموضوع مغلق.

مواضيع مشابهة