When I am retrieving data from the oracle database in the Springboot project am getting a No Datasource Set error kindly help me on this. Refer logs to sort the issue and thanks in advance.
Asked
Active
Viewed 1,584 times
-2
-
Please add more context to your question, to allow the community to reach out and help you. For example, specify the version type of your Oracle database, provide the version of Springboot being used in your project, provide the Spring configuration to connect to your database and a snippet of the exception logs for the datasource error. The more info provided will help some respond quicker to your query. – djmonki May 18 '22 at 10:11
1 Answers
0
in your application.yaml you can put sopmething like this:
spring:
datasource:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://localhost:1433;databaseName=MyDatabase;encrypt=false
username: sa
password: Passw0#rd
If you are using application.properties instead of yaml then u can change to have entries like below:
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=MyDatabase;encrypt=false
...
note that the driver and url values will have different values depending of your database provider. The example is for SQL Server
If you are trying to connect to an Oracle XE database instance then you don't specify the driver-class-name
(remove that entry) and as url you can have url: jdbc:oracle:thin:@localhost:1521:XE

Julian
- 3,678
- 7
- 40
- 72
-
-
I provided you with an Oracle XE URL example. The URL can differ lots depending on what Oracle database you are trying to access. I recommend you to consult Oracle documentation for your use case. Google could also take you to lots of examples, including here on stack overflow: https://stackoverflow.com/questions/1054105/url-string-format-for-connecting-to-oracle-database-with-jdbc – Julian May 18 '22 at 20:36
-