SQL Server why when I ran glass fish my app when read "insert.sql" give me access denied?

p3rjfoxz  于 2023-08-02  发布在  其他
关注(0)|答案(1)|浏览(86)

I gave permission on sql server management-

this is my insert code

SET IDENTITY_INSERT [Situation].[user].[USERS] ON;
INSERT INTO [Situation].[user].[USERS] (user_id, name, password, role, status, create_on, update_on, version, should_change_password, branch_id)
VALUES (9, 'admin', '21232f297a57a5a743894a0e4a801fc3', '0', '1', GETDATE(), GETDATE(), 1, 1, '000019');
SET IDENTITY_INSERT [Situation].[user].[USERS] OFF;

INSERT INTO [Situation].[user].[branch] (CODE, firstip, lastip, NAME)
VALUES ('000028', '10.12.0.1', '10.12.0.254', 'مركزي'),
    ('000037', '10.12.1.1', '10.12.1.254', 'بلواركشاورز'),
    ('000046', '10.28.0.1', '10.28.0.254', 'مير اصفهان'),
    ('000055', '10.12.2.1', '10.12.2.254', 'فر مانيه'),
    ('000064', '10.12.3.1', '10.12.3.254', 'آپادانا'),
    ('000073', '10.12.4.1', '10.12.4.254', 'آفريقا'),
    ('000082', '10.16.0.1', '10.16.0.254', ' استاد شهريار تبريز'),
    ('000091', '10.12.5.1', '10.12.5.254', 'ونك'),
    ('000105', '10.72.0.1', '10.72.1.254', 'كريمخان زند شيراز'),
    ('000114', '10.12.6.1', '10.12.6.254', 'پاسداران'),
    ('000123', '10.108.0.1', '10.108.0.254', 'رشت'),
    ('000132', '10.12.7.1', '10.12.7.254', 'كارگرشمالي'),
    ('000141', '10.84.0.1', '10.84.0.254', 'بلوار هفت تير كرج'),
    ('000159', '10.12.8.1', '10.12.8.254', 'مهرآباد جنوبي'),
    ('000168', '10.12.9.1', '10.12.9.254', 'ظفر'),
    ('000186', '10.48.0.1', '10.48.0.254', 'احمد آباد مشهد'),
    ('000195', '10.12.10.1', '10.12.10.254', 'جمهوري'),
    ('000209', '10.132.0.1', '10.132.0.254', 'يزد'),
    ('000218', '10.12.11.1', '10.12.11.254', 'سعادت آباد'),
    ('000227', '10.96.0.1', '10.96.0.254', 'بلوار دكتر بهشتي كرمانشاه'),
    ('000236', '10.76.0.1', '10.76.0.254', 'قزوين'),
    ('000245', '10.24.0.1', '10.24.0.254', 'خيابان امام اردبيل'),
    ('000254', '10.92.0.1', '10.92.0.254', 'كرمان'),
    ('000263', '10.12.12.1', '10.12.12.254', 'سعدي جنوبي'),
    ('000272', '10.28.1.1', '10.28.1.254', 'مطهري اصفهان'),
    ('000281', '10.124.0.1', '10.124.0.254', 'بندرعباس'),
    ('000299', '10.12.13.1', '10.12.13.254', 'شهرك وليعصر'),
    ('000304', '10.84.1.1', '10.84.1.254', 'مهرويلا كرج'),
    ('000313', '10.124.1.1', '10.124.1.254', 'كيش'),
    ('000322', '10.104.0.1', '10.104.0.254', 'گرگان'),
    ('000331', '10.88.0.1', '10.88.0.254', 'مهندس ادب سنندج'),
    ('000349', '10.64.0.1', '10.64.0.254', 'سمنان'),
    ('000358', '10.72.1.1', '10.72.1.254', 'امير كبير شيراز'),
    ('000367', '10.116.1.1', '10.116.1.254', 'ساري'),
    ('000376', '10.20.0.1', '10.20.0.254', 'اروميه'),
    ('000385', '10.48.1.1', '10.48.1.254', 'فردوسي مشهد'),
    ('000394', '10.116.0.1', '10.116.0.254', 'بابل'),
    ('000408', '10.12.14.1', '10.12.14.254', 'ستارخان'),
    ('000426', '10.12.15.1', '10.12.15.254', 'بهاران'),
    ('000435', '10.128.0.1', '10.128.0.254', 'همدان'),
    ('000444', '10.12.16.1', '10.12.16.254', 'دولت'),
    ('000453', '10.12.17.1', '10.12.17.254', 'قلهك'),
    ('000462', '10.116.2.1', '10.116.2.254', 'تنكابن'),
    ('000471', '10.56.0.1', '10.56.0.254', 'اهواز'),
    ('000489', '10.80.0.1', '10.80.0.254', 'قم'),
    ('000498', '10.12.18.1', '10.12.18.254', 'تهرانپارس'),
    ('000503', '10.12.19.1', '10.12.19.254', 'شهيد بهشتي'),
    ('000512', '10.56.1.1', '10.56.1.254', 'آبادان'),
    ('000521', '10.12.20.1', '10.12.20.254', 'عرفان'),
    ('000539', '10.12.21.1', '10.12.21.254', 'گلستان'),
    ('000548', '10.12.22.1', '10.12.22.254', 'باغ فردوس'),
    ('000557', '10.16.1.1', '10.16.1.254', 'وليعصرتبريز'),
    ('000566', '10.96.1.1', '10.96.1.254', 'فردوسي كرمانشاه'),
    ('000575', '10.16.2.1', '10.16.2.254', 'بازارتبريز'),
    ('000584', '10.24.1.1', '10.24.1.254', 'سيمتري اردبيل'),
    ('000593', '10.44.0.1', '10.44.0.254', 'ابوذر بيرجند'),
    ('000607', '10.92.1.1', '10.92.1.254', 'بلوار طالقاني رفسنج,ن'),
    ('000616', '10.116.3.1', '10.116.3.254', 'آمل'),
    ('000625', '10.120.0.1', '10.120.0.254', 'اراك'),
    ('000634', '10.36.1.1', '10.36.1.254', 'بوشهر'),
    ('000643', '10.12.27.1', '10.12.27.254', 'بلوارناهيد'),
    ('000652', '10.28.2.1', '10.28.2.254', 'كاشان'),
    ('000661', '10.12.23.1', '10.12.23.254', 'نارمك'),
    ('000679', '10.12.24.1', '10.12.24.254', 'ايران زمين'),
    ('000688', '10.12.25.1', '10.12.25.254', 'انقلاب'),
    ('000697', '10.12.59.1', '10.12.59.254', 'يوسف آباد شمالي'),
    ('000702', '10.12.28.1', '10.12.28.254', 'طالقاني شرقي'),
    ('000729', '10.28.3.1', '10.28.3.254', 'نظر غربي اصفهان'),
    ('000738', '10.12.30.1', '10.12.30.254', ' چيذر'),
    ('000747', '10.12.31.1', '10.12.31.254', 'خيام'),
    ('000756', '10.12.32.1', '10.12.32.254', 'آزادي'),
    ('000765', '10.12.33.1', '10.12.33.254', 'ملاصدرا'),
    ('000774', '10.12.34.1', '10.12.34.254', 'سردار جنگل'),
    ('000783', '10.12.35.1', '10.12.35.254', 'صاحبقرانيه'),
    ('000792', '10.12.37.1', '10.12.37.254', 'زعفرانيه'),
    ('000806', '10.12.36.1', '10.12.36.254', 'نفت شمالي'),
    ('000815', '10.60.0.1', '10.60.0.254', 'زنجان'),
    ('000824', '10.12.38.1', '10.12.38.254', 'جاده مخصوص کرج'),
    ('000833', '10.68.0.1', '10.68.0.254', 'زاهدان'),
    ('000842', '10.12.41.1', '12.12.41.254', 'مقدس اردبيلي'),
    ('000851', '10.12.40.1', '10.12.40.254', 'كريمخان'),
    ('000869', '10.12.39.1', '10.12.39.254', 'ميرداماد'),
    ('000878', '10.12.42.1', '10.12.42.254', 'آقابزرگي'),
    ('000887', '10.12.43.1', '10.12.43.254', 'اندرزگو شرقي'),
    ('000896', '10.132.1.1', '10.132.1.254', 'صفائيه يزد'),
    ('000901', '10.28.4.1', '10.28.4.254', 'سيتي سنتر اصفهان'),
    ('000919', '10.104.1.1', '10.104.1.254', 'گنبد كاووس'),
    ('000928', '10.12.44.1', '10.12.44.254', '15 خرداد'),
    ('000937', '10.112.0.1', '10.112.0.254', 'خرم آباد'),
    ('000946', '10.12.47.1', '10.12.47.254', 'عمار'),
    ('000955', '10.108.1.1', '10.108.1.254', 'مطهري رشت'),
    ('000964', '10.92.2.1', '10.92.2.254', 'بلوار نصر كرمان'),
    ('000973', '10.12.48.1', '10.12.48.254', 'فرشته'),
    ('000982', '10.12.49.1', '10.12.49.254', 'پونک'),
    ('000991', '10.12.50.1', '10.12.50.254', 'عرفان نیایش'),
    ('001003', '10.12.45.1', '10.12.45.254', 'ولنجك'),
    ('001012', '10.12.46.1', '10.12.46.254', 'نياوران'),
    ('001021', '10.12.51.1', '10.12.51.254', 'بلوار فردوس شرقي'),
    ('001039', '10.12.52.1', '10.12.52.254', 'فاطمي'),
    ('001048', '10.12.53.1', '10.12.53.254', 'خيابان مرجان'),
    ('001057', '10.12.56.1', '10.12.56.254', 'مديكو'),
    ('001066', '10.72.2.1', '10.72.2.254', 'ستارخان شيراز'),
    ('001075', '10.12.54.1', '10.12.54.254', 'صادقيه'),
    ('001084', '10.48.2.1', '10.48.2.254', 'بلوار معلم مشهد'),
    ('001093', '10.12.55.1', '10.12.55.254', 'سرو شرقي'),
    ('001107', '10.12.58.1', '10.12.58.254', 'پل رومي'),
    ('001116', '10.12.57.1', '10.12.57.254', 'مطهري غربي'),
    ('000019', '0.0.0.0', '254.254.254.254', 'دفتر مركزی')
;

and this is my xml code :

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
             xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="Eclipselink_JPA" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>jdbc/Situation</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="javax.persistence.schema-generation.database.action" value="create"/>
            <property name="eclipselink.weaving" value="static"/>
            <property name="eclipselink.target-database" value="SQLServer"/>
            <property name="eclipselink.logging.level" value="FINEST"/>
            <property name="eclipselink.logging.parameters" value="true"/>
            <property name="eclipselink.logging.level.sql" value="ALL"/>
            <property name="eclipselink.query-results-cache" value="false"/>
        </properties>
    </persistence-unit>
    <persistence-unit name="Eclipselink_JPA1" transaction-type="JTA">
        <properties>
            <property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
            <property name="javax.persistence.jdbc.url" value="jdbc:sqlserver://localhost;databaseName=Situation"/>
            <property name="javax.persistence.jdbc.user" value="user"/>
            <property name="javax.persistence.jdbc.password" value="Tt123456"/>
            <property name="eclipselink.ddl-generation" value="create-tables"/>
            <property name="eclipselink.ddl-generation.output-mode" value="database"/>
        </properties>
    </persistence-unit>
</persistence>

When I ran the app on glass fish server the error is :

C:\Users\t.bahmani\Downloads\Compressed\glassfish4\glassfish\domains\domain1\applications\situation\META-INF\insert.sql (Access is denied)

If I had written something tell, I am Realy stuck on this problem

ntjbwcob

ntjbwcob1#

The error tells you that you have a permission problem.

First thing to check is whether the OS user with whom you attempt to run the query has access rights to
C:\Users\t.bahmani\Downloads\Compressed\glassfish4\glassfish\domains\domain1\applications\situation\META-INF\insert.sql

You will need to find out which OS user are you running SQL Server Management with, try to log in with that user and see whether you are able to open the file at your location. If not, then it's a privilege problem on that file and you need to grant those privileges to this user, or run SQL Server Management with a user that has access rights to that file.

Second, you need to check the privileges of the DB user, see whether you can simply connect with this user and run an insert command of your preference. If not, then you will need to sort out credentials and access rights

Finally, make sure that this user is allowed to run SQL scripts from files.

Since you lack privileges here, we can be fairly certain that you lack one of these specific privileges.

相关问题