• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

how to show database table with webservice?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello
i want to retrive database table as service in java
i use Resultset,but give error it
error is:C:\Users\Documents\NetBeansProjects\QAProject1\nbproject\build-impl.xml:553: The module has not been deployed.
this problem is related to the following location:
at javax.servlet.jsp.jstl.sql.Result
at private javax.servlet.jsp.jstl.sql.Result servicepac.jaxws.ShowOpenResponse._return
at servicepac.jaxws.ShowOpenResponse

[cod]

@WebService()
public class qaservice {





Logic obj=new Logic();
@WebMethod(operationName="showOpen")
public Result showOpen(){
Result res=obj.showOpenq();
return res;
}
}



//--------------
public class Logic {
DB db=new DB("localhost","testqa",3306,"root","123");

public Logic(){}
public Result showOpenq() {
db.connect();
String sql="SELECT * FROM questions where openq=true";
//sql=String.format(sql);
Result rs=db.ShowOpenq(sql);
db.disConnect();
return rs;
}
}
//--------------------
/---------------------

public class DB {

public String serverName;
public String dbName;
public int port;
public String userName;
public String passWord;

private Connection connection;
private Statement st;

public DB(String serverName,String dbName, int port, String userName,String passWord) {

this.serverName = serverName;
this.dbName = dbName;
this.port = port;
this.userName=userName;
this.passWord=passWord;

try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception e) {
System.err.println(e.getMessage());
}
}

public void connect(){
try {
String url = "jdbc:mysql://"+serverName+":"+port+"/"+dbName;
connection = DriverManager.getConnection(url,userName,passWord);
st = connection.createStatement();
} catch (Exception e) {
System.err.println(e.getMessage());
}
}

public void disConnect(){
try {
st.close();
connection.close();
} catch (Exception e) {
System.err.println(e.getMessage());
}
}

public Result ShowOpenq(String sql){
try {
st.executeQuery(sql);
} catch (SQLException ex) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
}
ResultSet rs = null;
try {
rs = st.executeQuery(sql);
} catch (SQLException ex) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
}
Result res= ResultSupport.toResult(rs);
try {
rs.close();
} catch (SQLException ex) {
Logger.getLogger(DB.class.getName()).log(Level.SEVERE, null, ex);
}


return res;}
} [/code]
excuseme as bad english.
 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags and TellTheDetails because 'it can not deploy' is not a valid problem description.
 
reply
    Bookmark Topic Watch Topic
  • New Topic