Skip to content

Commit

Permalink
dependency inyection implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
christian130 committed Sep 23, 2016
1 parent 8878721 commit b6f8c70
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
8 changes: 6 additions & 2 deletions src/main/java/conexus/IndexController.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package conexus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import conexusDTO.UsuarioDTO;
import implDAO.AppConfig;
import implDAO.UsuarioDAO;
@Controller
public class IndexController {
@Autowired
AppConfig getMyConnection;

@RequestMapping("/")
public String login(Model model) {
public String login(Model model) {

return "login";
}
@RequestMapping("/citas")
Expand Down
20 changes: 15 additions & 5 deletions src/main/java/implDAO/AppConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package implDAO;

import java.sql.Connection;

import java.sql.ResultSet;
import java.sql.Statement;
import org.springframework.context.ApplicationContext;
Expand All @@ -10,24 +11,24 @@

import conexusDTO.UsuarioDTO;
import oracle.jdbc.pool.OracleDataSource;


@Configuration
public class AppConfig {


private Connection myConnection = null;
private Connection myConnection;
private ApplicationContext context;
public AppConfig() {


}

@Bean
public boolean getLogin(UsuarioDTO objUsuarioDTO) throws Exception {

try {
ApplicationContext context = new GenericXmlApplicationContext("application-context.xml");
OracleDataSource dataSource= (OracleDataSource) context.getBean("dataSource");
Connection myConnection = dataSource.getConnection();
Statement sqlStatement = myConnection.createStatement();
Statement sqlStatement = this.getMyConnection().createStatement();
String readRecordSQL = "select * from USUARIO_K78 where ROWNUM < 2 and ROWNUM >0";
//String readRecordSQL = "select * from USUARIO_K78 where ROWNUM < 2 and ROWNUM >0 and LOGIN like '%"+objUsuarioDTO.getLogin()+"%' and CLAVE like '%"+objUsuarioDTO.getPasssha256()+"%'";
ResultSet myResultSet = sqlStatement.executeQuery(readRecordSQL);
Expand All @@ -46,6 +47,15 @@ public boolean getLogin(UsuarioDTO objUsuarioDTO) throws Exception {


}
@Bean
public Connection getMyConnection() throws Exception {
ApplicationContext context = new GenericXmlApplicationContext("application-context.xml");
OracleDataSource dataSource= (OracleDataSource) context.getBean("dataSource");
Connection myConnection = dataSource.getConnection();
return myConnection;
}





Expand Down

0 comments on commit b6f8c70

Please sign in to comment.