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

لماذا لا تظهر نتيجة الاستعلام

بدأه Daliagn في 19 يوليو 2011 · 20 رد · 669 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

كتبت هذا الكود ولا توجد به اي اخطاء

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCResultSetExample {
        Connection connection = null;

        public JDBCResultSetExample() {
                try {
                        // Loading the driver
                        Class.forName("org.postgresql.Driver");
                } catch (ClassNotFoundException e) {
                        System.out.println(e.toString());
                }
        }

        public Connection createConnection() {
                Connection con = null;
                if (connection != null) {
                        System.out.println("Cant create a connection");
                } else {
                        try {
                                // Crating a Connection to the Student database
                                con = DriverManager.getConnection(
                                                "jdbc:postgresql://localhost:5432/Database2011", "postgres",
                                                "dalia123");
                                System.out.println("Connection created Successfully");
                        } catch (SQLException e) {
                                System.out.println(e.toString());
                        }
                }
                return con;
        }

        public static void main(String[] args) throws SQLException {
                JDBCResultSetExample resultSetExample = new JDBCResultSetExample();
                Connection connection = resultSetExample.createConnection();
                try {
                        // creating a statement object
                        Statement statement = connection.createStatement(
                                        ResultSet.TYPE_SCROLL_INSENSITIVE,
                                        ResultSet.CONCUR_UPDATABLE);
                        String query = "SELECT descrip FROM prod";
                        // executing a query string and storing it into the resultSet object
                        ResultSet resultSet = statement.executeQuery(query);
                        System.out.println("Before Updating....................\n");
                        while (resultSet.next()) {
                                // Printing results to the console
                                System.out.println("descrip- " + resultSet.getString("descrip"));

                        }
                        // setting the row to we have to update
                        resultSet.first();
                        // Setting the updating String
                        resultSet.updateString("descrip", "wamp");
                        // Updating the first row
                        resultSet.updateRow();
                        System.out.println("\n\n After Updatig.......................\n");
                        while (resultSet.next()) {
                                // Printing results to the console
                                System.out.println( "descrip- " + resultSet.getString("descrip"));
                        }
                } catch (Exception e) {
                        System.out.println(e.toString());
                } finally {
                        connection.close();
                }
        }

ولكني لا احصل على اي نتيجة وانما يظهر الاتي

PostgreSQL 8.4 JDBC3 (build 702)

Found in: jar:file:/C:/Users/Dalia/Desktop/postgresql-8.4-702.jdbc3.jar!/org/postgresql/Driver.class

ماهي المشكلة؟؟

#2

ارجو المساعدة يا اخوان

#3
Daliagn كتب:

ارجو المساعدة يا اخوان

اين قاعده البيانات التى تعملين عليها

Software Developer
Mahmoudkelany.com


 

#4

هل تقصد في الكود

jdbc:postgresql://localhost:5432/Database2011

#5

انا اقصد قاعده البيانات نفسها

وليس الـ URL Connection

Software Developer
Mahmoudkelany.com


 

#6

هل اقوم بإرفاقها ؟

في المرفقات قاعدة البيانات المستخدمة

pgimply.sql

#7
Daliagn كتب:

هل اقوم بإرفاقها ؟

لم استطع اضافه قاعده البيانات لدى

هل من الممكن ان تشرحى لى كيفيه وضعها

لانى لم اجد فقط غير restore ولكنها تاخذ ملف نوعه backup وليس SQL

او ممكن ترفقى لى صوره مثل هذه من قاعده البيانات الخاصه بك

post-217802-011686100 1311108838_thumb.p

بالتوفيق

المرفقات
postgres.png

Software Developer
Mahmoudkelany.com


 

#8

يمكن اضافتها

بالذهاب لقائمة tools واختيار query

ثم فتح الملف اللذي قمت بإرفاقه وتشغيله بعد ذلك ستجد جميع الجداول والبيانات في قاعدة البيانات

#9
Daliagn كتب:

يمكن اضافتها

بالذهاب لقائمة tools واختيار query

ثم فتح الملف اللذي قمت بإرفاقه وتشغيله بعد ذلك ستجد جميع الجداول والبيانات في قاعدة البيانات

ما انا بعمل كدا بقالى فتره ولكن بيظهر لى مشكله

post-217802-005282900 1311109402_thumb.p

بيقولى مش لاقى Schema

اعطينى صوره كما ذكرت لك وان شاء الله هاعطيكى الحل :)

المرفقات
error.png

Software Developer
Mahmoudkelany.com


 

#10

اوكي صورة الداتا بيس او صورة الكويري؟

#11

صوره زى اول صوره انا وضتعتها بنفس الشكل دا

Software Developer
Mahmoudkelany.com


 

#12
Mahmoud Kelany كتب:

صوره زى اول صوره انا وضتعتها بنفس الشكل دا

ارفقت الصورة

post-247733-065317600 1311110315_thumb.j

المرفقات
DB1.jpg
#13

جربى كدا

/**
 *
 * @author JKelany
 */
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCResultSetExample {

	Connection connection = null;

	public JDBCResultSetExample() {
    	try {
        	// Loading the driver
        	Class.forName("org.postgresql.Driver");
    	} catch (ClassNotFoundException e) {
        	System.out.println(e.toString());
    	}
	}

	public Connection createConnection() {
    	Connection con = null;
    	if (connection != null) {
        	System.out.println("Cant create a connection");
    	} else {
        	try {
            	// Crating a Connection to the Student database
            	con = DriverManager.getConnection(
                    	"jdbc:postgresql://localhost:5432/Database5559", "postgres",
                    	"dalia123");
            	System.out.println("Connection created Successfully");
        	} catch (SQLException e) {
            	e.printStackTrace();
        	}
    	}
    	return con;
	}

	public static void main(String[] args) throws SQLException {
    	JDBCResultSetExample resultSetExample = new JDBCResultSetExample();
    	Connection connection = resultSetExample.createConnection();
    	try {
        	// creating a statement object
        	Statement statement = connection.createStatement(
                	ResultSet.TYPE_SCROLL_INSENSITIVE,
                	ResultSet.CONCUR_UPDATABLE);
        	String query = "SELECT descrip FROM prod";
        	// executing a query string and storing it into the resultSet object
        	ResultSet resultSet = statement.executeQuery(query);
        	System.out.println("Before Updating....................\n");
        	while (resultSet.next()) {
            	// Printing results to the console
            	System.out.println("descrip- " + resultSet.getString("descrip"));

        	}
        	// setting the row to we have to update
        	resultSet.first();
        	// Setting the updating String
        	resultSet.updateString("descrip", "wamp");
        	// Updating the first row
        	resultSet.updateRow();
        	System.out.println("\n\n After Updatig.......................\n");
        	while (resultSet.next()) {
            	// Printing results to the console
            	System.out.println("descrip- " + resultSet.getString("descrip"));
        	}
    	} catch (Exception e) {
        	System.out.println(e.toString());
    	} finally {
        	connection.close();
    	}

	}
}
1

Software Developer
Mahmoudkelany.com


 

#14

نفس الرسالة تظهرلي

PostgreSQL 8.4 JDBC3 (build 702)

Found in: jar:file:/C:/Users/Dalia/Desktop/postgresql-8.4-702.jdbc3.jar!/org/postgresql/Driver.class

#15
Daliagn كتب:

نفس الرسالة تظهرلي

PostgreSQL 8.4 JDBC3 (build 702)

Found in: jar:file:/C:/Users/Dalia/Desktop/postgresql-8.4-702.jdbc3.jar!/org/postgresql/Driver.class

طيب انتى نسخه قاعده البيانات اللى انتى محملاها رقمها كام ؟

يعنى انا مثلا مستخدم دا postgresql-9.0.4-1-windows.exe

انتى مستخدمه ايه ؟؟

Software Developer
Mahmoudkelany.com


 

#16
Mahmoud Kelany كتب:

طيب انتى نسخه قاعده البيانات اللى انتى محملاها رقمها كام ؟

يعنى انا مثلا مستخدم دا postgresql-9.0.4-1-windows.exe

انتى مستخدمه ايه ؟؟

نسخة 8.4

طيب ايش معنى الرسالة اللي بتظهرلي؟

وهل ممكن تكون المشكلة في الكمبيوتر؟

انا بشتغل على الاكليبس للجافا هل فيه برنامج اسهل منه؟ ولا ما له دخل في النتيجة اللي بتظهرلي

#17

انا بصراحه لم اتعامل مع الـ JDBC3 ولا اعلم حتى ما هى

لكن اللى انتى بتتعاملى معاه فالكود بتاعك JDBC2

وانتى تقريبا بتستخدمى JDBC3 حملى الـ JDBC2

http://jdbc.postgresql.org/download.html

Software Developer
Mahmoudkelany.com


 

#18

بس انا بستخدم 8.4 دا الاصدار من الـpostgresql

ومكتوب عنده JDBC3 or JDBC 4

#19

امممم فعلا مش اخدت بالى

بس ليه مش راضى يتشغل :(

ممكن يكون عندك فى مسار ملف الـ jar نفسه

يكون فيه خطأ

Software Developer
Mahmoudkelany.com


 

#20

ما الخطأ الذي تحصلين عليه؟

تحياتي

حزمة المحرك الإصدارة 0.8

أي أحد يجد أني ظلمته فليراسلني

وبإذن الله لو كان له حق سيأخذه

728x90.png

#21

كما تقول انه

اقتباس

PostgreSQL 8.4 JDBC3 (build 702)

Found in: jar:file:/C:/Users/Dalia/Desktop/postgresql-8.4-702.jdbc3.jar!/org/postgresql/Driver.class

لكن اعتقد دلوقتى اتحل ومفيش مشاكل

Software Developer
Mahmoudkelany.com


 

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