Spring Tutorial 38 - Adding Spring and DataSource Configuration

preview_player
Показать описание
We'll now add the Spring framework to our JDBC project. We'll add dependency injection to our Main and DAO class. We'll also learn how to configure DataSource as a Spring bean and supply connection parameters to it in the XML file.
Рекомендации по теме
Комментарии
Автор

Thank you Koushik! These tutorials are top-notch. I know it's been about 18 months, but these are great! I appreciate how easy you made it seem to set up a connection to the Derby database with Spring. Keep the tutorials coming. They are a wonderful asset to Youtube and the entire Java and Spring programming community!

KentOJohnson
Автор

Thank you sir, thank you very much. You've saved my life from error 500😊

aryacachari
Автор

Whoever is using commons-dpcp2-2.1.1 or greater, if you get an error because of "maxActive" then change it to "maxTotal". They have changed property name "maxActive" to "maxTotal".


Also class name is and not just add dbcp2 as above.

MaheshPaulC
Автор

Thank you very much Koushik, i am actually downloading all your videos, about spring and struts, and i am good to consume them all !, thank you very much

marouanabbessi
Автор

Hi Koushik... You are awesome... Please post many videos in spring... Only after seeing our vidoes i started to learn spring.. I am learning from only your videos... Help everyone to educate.. Thanks very much

jamyou
Автор

Fantastic stuff Koushik! nothing else like it out there! Keep on keeping on!

mateuszalmannai
Автор

Thank you for the lesson! Everything was clear.

ProfGid
Автор

awesome explanation Sir.... u really are a teacher... thank you for the stuff

nik
Автор

Just a note on the Autowired annotation.  Since he used Autowired, it wasn't necessary to set the getter AND setter for the dataSource.  Autowired takes care of the setter automatically (so remove it and it still works great).

ronniejohns
Автор

When using the Apache DBCP libs to implement connection pooling, I kept on getting NullPointerExceptions in main. My solution was to replace the Apache DBCP libs with c3p0 and it worked.

shalipoto
Автор

getting null pointer exception while accessing datasource in dao class, somehow datasource property is not being initialized properly it seems

deveshgoyal
Автор

If you are getting error with dbcp please check the jars package name.
mine was dbcp2 not dbcp Both pool and dbcp should be latest version.
And maxActive should be maxTotal

<?xml version="1.0" encoding="UTF-8"?>

<context:annotation-config/>
<context:component-scan
<bean id="dataSource"
<property name="driverClassName" value =
<property name="url"
<property name="initialSize" value="2"/>
<property name="maxTotal" value="5"/>
</bean>
</beans>

sahithichowdary
Автор

When I create DataSource object it does not let me generate getters and Setters. And and gives an error while declaring it private ! Please help someone, I am using Spring 4

avs
Автор

I took me some times to find out the Spring Data jdbc Extension for the project...

MissPiggyM
Автор

When I use @Component in the JdbcDaoImpl.java and <context:annotation-config/>
<context:component-scan in spring.xml.

I get Unexpected exception parsing XML document from class path resource [spring.xml]; nested exception is Context namespace element 'annotation-config' and its parser class are only available on JDK 1.5 and higher.


Please can you tell me what is the error ASAP :(.. Coz iam stuck :'(

ashwinneo
Автор

its working just fine but when i change the class in spring.xml from to it gives me a nullpoint exception from main . Does anyone know what might be the problem ? .. i have inserted the common- pool and comon-dbcp jars into the path.. its odd

Andrei
Автор

my problem he didn't take much time to explain (initialSize, maxActive) properties therefore can anyone help me to understand property initialsize and make sure i am correct that i think maxActive property used for providing limited connections based on value

balakrishnan
Автор

sir, Please provide we us videos of hibernate without annotations.because i am fresher about hibernate.

amitkumarsaini
Автор

if you are getting "NullPointerException", then replace your ojdbc14.jar to ojdbc6.jar also replace "maxActive" to "maxTotal". :)

kemosabe
Автор

Check imports if you have problems. Make sure you use these interfaces:
import java.sql.PreparedStatement;
import java.sql.ResultSet;
And dont cast anything.

matleoon
join shbcf.ru