Lost in the multitude of Java API's and XML configuration.
I am trying to create an app with the Spring MVC but struggling with the XML configuration.
I want to be able to connect to a mysql database... but I am struggling to find any concise way of how to do it. I do not want to use Hibernate or any additional frameworks, the JDBC will be adequate on it's own.
I would just like to be able to create a database connection and access to a String variable that can change the query as necessary. I think the problem lies within the xml configuration, but I may be wrong.
I have pasted the details shown below in the application-context.xml file, but the server cannot be built unless I remove them. I am not sure if I am missing something simple!
<bean id="JdbcDao" class="com.bcash.DbAccess.JdbcDao">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="com.mysql.jdbc.Driver"
p:url="jdbc:mysql://localhost:3306/db_name"
p:username="root"
p:password=""
destroy-method="close" />
This is the associated class that I wrote for the xml declaration
package com.bcash.DbAccess;
import javax.sql.DataSource;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
public class JdbcDao {
private JdbcTemplate jdbcTemplate;
protected String query = "INSERT INTO user('username','email','password','access_level') VALUES ('admin','[email protected]','testPassWord','admin')";
public void insertUser(){
try{
jdbcTemplate.update(query);
} catch(DataAccessException e){
String error = e.getMessage();
System.out.println(error);
}
}
}
The only error that I get is that the server could not be deployed on line 726 of the ant build script
<target if="netbeans.home" name="-run-deploy-nb">
<nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
</target>
Although, I am okay with PHP, I am a little confused as I am fairly new to Java.
Thanks in advance