use of org.springframework.jdbc.datasource.DriverManagerDataSource in project SpringStepByStep by JavaProgrammerLB.
the class DatabaseConfig method dataSource.
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/myminitwit");
dataSource.setUsername("root");
dataSource.setPassword("root");
return dataSource;
}
use of org.springframework.jdbc.datasource.DriverManagerDataSource in project spring-framework by spring-projects.
the class RdbmsOperationTests method setTypeAfterCompile.
@Test
public void setTypeAfterCompile() {
operation.setDataSource(new DriverManagerDataSource());
operation.setSql("select * from mytable");
operation.compile();
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() -> operation.setTypes(new int[] { Types.INTEGER }));
}
use of org.springframework.jdbc.datasource.DriverManagerDataSource in project spring-framework by spring-projects.
the class RdbmsOperationTests method validateInOutParameter.
@Test
public void validateInOutParameter() {
operation.setDataSource(new DriverManagerDataSource());
operation.setSql("DUMMY_PROC");
operation.declareParameter(new SqlOutParameter("DUMMY_OUT_PARAM", Types.VARCHAR));
operation.declareParameter(new SqlInOutParameter("DUMMY_IN_OUT_PARAM", Types.VARCHAR));
operation.validateParameters(new Object[] { "DUMMY_VALUE1", "DUMMY_VALUE2" });
}
use of org.springframework.jdbc.datasource.DriverManagerDataSource in project spring-framework by spring-projects.
the class RdbmsOperationTests method parametersSetWithList.
@Test
public void parametersSetWithList() {
DataSource ds = new DriverManagerDataSource();
operation.setDataSource(ds);
operation.setSql("select * from mytable where one = ? and two = ?");
operation.setParameters(new SqlParameter[] { new SqlParameter("one", Types.NUMERIC), new SqlParameter("two", Types.NUMERIC) });
operation.afterPropertiesSet();
operation.validateParameters(new Object[] { 1, "2" });
assertThat(operation.getDeclaredParameters().size()).isEqualTo(2);
}
use of org.springframework.jdbc.datasource.DriverManagerDataSource in project spring-framework by spring-projects.
the class RdbmsOperationTests method compileTwice.
@Test
public void compileTwice() {
operation.setDataSource(new DriverManagerDataSource());
operation.setSql("select * from mytable");
operation.setTypes(null);
operation.compile();
operation.compile();
}
Aggregations