Im trying to connect to the mariadb server in jdbc and call my stored procedure but im getting this error.
Ive also tried:
'''GRANT all ON mysql.proc TO 'Gruppe18'#'i3ED6FBF0.versanet.det';'''
but in mysql i got access denied error.
And the server is from university so I dont have full access on it.
enter image description here
The image shows that you're using named parameters, which means that the JDBC driver needs to query the meta-data of the stored procedure to learn what those parameters are.
Your user is not authorized to query that meta-data.
Solution: Use positional parameters.
Related
So I recently set up a database through Microsoft Azure using clearDB's MySQL db.
I connected to it through java with the given server, name and user credentials given to me, and everything worked fine, for eight hours... suddenly out of nowhere when I connected (without changing anything that actually had to do with the connection) I got the error message "Access denied for user 'my-given-username'#'%' to database 'my-db-name'"
I double checked everything, and even made a new program trying to connect, but same error message. On the Azure portal and clearDB page it says that the status of the DB is healthy, that it's absolutely not filled up (1.09 %) and that the number of connections is 0 out of maximum 4.
I made a new database the same way, changed the connecting settings accordingly and everything worked just fine!
Does anyone have any idea what might be wrong?
Even though everything is working now with the new DB, I'm afraid the same thing will happen to this one after a while.
Per my experience, the issue is normally related to MySQL user privileges.
I tried to test several sql query in Java to reproduce this issue on Azure ClearDB, and found these SQL cases below caused this issue.
Execute the sql CREATE DATABASE <new-db> in current database
Connect the Jdbc Url jdbc:mysql://<db-host>:3306/mysqlwith current database user & password
Execute the sql query after some grant operation, such as cancel select privilege on table
Although I don't know what sql query your Java program do caused this issue, I think these cases can help you checking.
Any concern, please feel free to let me know.
we just started learning about sql statements and such, and right now i am totally confused on how to do this:
I need to access the database of another computer (we are using mysql workbench) using java codes
What i have done so far:
grant all privileges using '%'
i can already connect to the database (mysql) in my own computer (java codes and jdbc)
my problems are:
what are the steps do i need to do to be able to access the database from another computer, there are no direct answers in google...and now i am totally confused on how to do this because every site keep on telling me about cpanel, which i dont know how to have one...then this remote access that requires me to change my sql server configuration, i dont know how to find this...
CAN SOMEONE GIVE ME A STEP BY STEP SETTING/SETUP i need to do, to be able to access the database/connection from another computer? i only need the Normal steps, no need for safety/security setups and descriptive steps, i can do the rest of specific research on Google
SOLUTION
Hey Just configure that system IP in the JDBC connection call then you will be able top connect and retrieve the data in the Java Layer.
String DB_URL = "jdbc:mysql://localhost/EMP";
String USER = "username";
String PASS = "password";
Connection conn = DriverManager.getConnection(DB_URL,USER,PASS);
Instead of "localhost" give your destination MySQL system IP address.
Just run the the mysql in one device then get that device Ip address, then on the other device use the http://IPADDRESS:8081/yourWebsite
for example instead of
instead of http://localhost:8081/yourWebsite = http://271.1.1.10:8081/yourWebsite
it will work from there, not need to configure anything. the other device will be using the same project and same database
note both devices should be on the same network
I'm trying to write a code where i need to keep some data in database tables.
I have learned how to use SQL. My problem is that I want this program to run on different computers while having access to the same database.
Any suggestions ?
Thanks
You'll have to run an SQL server on a computer (ie: with mySQL, SQL Server, etc.). You will run queries against the tables that are stored on this database. There are already a lot of resources online with making a database connection to a server.
Just keep database system running in a machine, and instead of pointing to localhost in your JDBC URL, point to the machine's IP Address.
I would personally recommend setting up a script on a host machine and letting it communicate with the database, and have your program communicate with the script. This way, you won't have to keep your database login credentials in your Java program, which could be dangerous.
I was using MySQL for my application. And i was using hibernate in my spring mvc application.
So all the tables are automatically created in my databse (MyApp).
I wrote a command
create database Myapp
in Mysql command prompt.
And when i ran my application, all the tables were created automatically inside Myapp.
In my hibernate config file , to connect to Mysql i have used the following url
jdbc:mysql://localhost:3306/Myapp
But now i want to change my database client to Oracle.
But i have seen in oracle the URL is given as
jdbc:oracle:thin:#localhost:1521:xe
So the database is not mentioned in the URL?
And also the command i wrote to create database in Mysql is not working in oracle.
How i can do this?
Following table lists down popular JDBC driver names and database URL.
RDBMS JDBC driver name URL format
MySQL com.mysql.jdbc.Driver jdbc:mysql://hostname/ databaseName
ORACLE oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:#hostname:portNumber:databaseName
DB2 COM.ibm.db2.jdbc.net.DB2Driver jdbc:db2:hostname:port Number/databaseName
Sybase com.sybase.jdbc.SybDriver jdbc:sybase:Tds:hostname: port Number/databaseNam
So the database is not mentioned in the URL?
It is mentioned. In your example jdbc:oracle:thin:#localhost:1521:xe, **xe** is the database service name similar to Myapp in your MySQL example.
Try to read the following links below
http://www.mkyong.com/jdbc/connect-to-oracle-db-via-jdbc-driver-java/
http://www.rgagnon.com/javadetails/java-0112.html
and download the drivers here and i think it contains some examples for you
http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
and for creating the database please watch this tutorial video
http://www.youtube.com/watch?v=3ZQ9ihJYRyM
i want what should be given in DriverManager.getConnection() when i want to access all tables from ms-access
Have a look at DriverManager.getConnection(String url, Properties info). What problem doesn't this solve?
I think you want to connect to an MS Access DB without creating a DSN.
In any case this works fine with acess everytime.
DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/data/data.MDB","","");
Change the DBQ argument to your MDB file.