how to check database user permission on fmp database using JAVA - java

I want to know how to run FileMaker(FMP pro) database command in java. I have got the connection to database,but not sure how to execute below query.
Get(AccountPrivilegeSetName)
ref:
http://www.filemaker.com/11help/html/func_ref2.32.4.html#1051898

You will need to add a calculation field in FileMaker to return as the result of the JDBC query. This is because you cannot call functions via JDBC, you can only retrieve field values.

Related

Unable to use Crate JDBC 2.6.0 in read only mode

I want to restrict delete/update statements
This is what I am trying
ResultSet rs = stmt.executeQuery("delete from test where id=243640033")
Ideally executeQuery method of JDBC should not allow update, delete and etc. But Crate Database is simply executing delete queries. Then I tried connection.setReadOnly(true) and it did not work
Is there any way to restrict Crate JDBC doing update/delete/drop operations from stmt.executeQuery(somequery) method ?
You could create a CrateDB user with Data Query Language (DQL) privileges only and subsequently use this user to connect with JDBC. This will prevent all INSERT / UPDATE / DELETE / DROP operations.
CREATE USER read_only WITH (password = '<secure-password>');
GRANT DQL TO read_only;
If required you can further restrict access only to specific schemas, tables or views. Compare the documentation on how to achieve this.

Update and Return Updated column using returning keyword in same query in java jdbc code

update account set lastusedval=lastusedval+1 where isactive=1 returning
lastusedval;
How to execute above query in java?
when i tried to execute in oracle its working but in java hibernate/jpa no way to store return value in update query.
By executing above query intention is to apply lock on db level when more than 1 request comes
Using jdbc prepared statement with registeroutparameter might help you to resolve this issue.
Creating an UPDATE RETURNING query in Hibernate

Fetch result set from a postgres Stored procedure in java

I created a postgres function which returns a set of ref cursors. When I call the stored procedure from java the JDBC statement build is
select * from ga_rpt_movement('CODE','2018-5-10','2018-5-10','2018-5-10','C','STAT1','2018-5-10','2018-5-10','12344','A','T','34',25,50,'M','1','firstname',0,10) as result
When I run the same query on postgres terminal it gives me the four coursors.
Now I am not able to understand how do I fetch this cursor data in java.
Any suggestions, ideas are welcome and appreciated.
Result set when I run this query on postgres terminal look like this :
p_cr_personstatus
p_cr_identification
p_cr_phone
p_cr_count
(4 rows)
I am trying to implement this using spring JPA only.

Java Connection String to query from two database

I am having a problem. I have a query that checks one database table and updates another database table. I am using MySQL 5.1
UPDATE dldd.temp,test.temp
SET test.temp.name = dldd.temp.word
WHERE dldd.temp.id = test.temp.id
this is my SQL statement that is working fine. Now I want to execute this statement using Java PreparedStatement . The problem is I don't know how to write the Connection String to select two database i.e
"jdbc:mysql://localhost:3306/"+dbname+"?characterEncoding=UTF-8"
What should come in place of dbname. Can I select multiple db there.
Have a look at http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html.
If the database is not specified, the connection is made with no default database. In this case, either call the setCatalog() method on the Connection instance, or fully specify table names using the database name (that is, SELECT dbname.tablename.colname FROM dbname.tablename...) in your SQL. Opening a connection without specifying the database to use is generally only useful when building tools that work with multiple databases, such as GUI database managers.

Change Table names in derby database using entitymanager

I am using an APACHE DERBY database, and basing my database interactions on EntityManager, and I don't want to use JDBC class to build a query to change my tables' names (i just need to put a prefix to each new user to the application, but have the same structure of tables), such as:
//em stands for EntityManager object
Query tableNamesQuery= em.createNamedQuery("RENAME TABLE SCHEMA.EMP_ACT TO EMPLOYEE_ACT");
em.executeUpdate();
// ... rest of the function's work
// The command works from the database command prompt but i don't know how to use it in a program
//Or as i know you can't change system tables data, but here's the code
Query tableNamesQuery= em.createNamedQuery("UPDATE SYS.SYSTABLES SET TABLENAME='NEW_TABLE_NAME' WHERE TABLETYPE='T'");
em.executeUpdate();
// ... rest of the function's work
My questions are :
This syntax is correct?
Will it work?
Is there any other alternative?
Should I just use the SYS.SYSTABLES and find all the tables that has 'T' as tabletype and alter their name their, will it change the access name ?
I think you're looking for the RENAME TABLE statement: http://db.apache.org/derby/docs/10.10/ref/rrefsqljrenametablestatement.html
Don't just issue update statements against the system catalogs, you will corrupt your database.

Categories