Fórumok
How can Query in database table whitout service builder?
habib zare, módosítva 11 év-val korábban
How can Query in database table whitout service builder?
Junior Member Bejegyzések: 58 Csatlakozás dátuma: 2012.10.28. Legújabb bejegyzések
There is no entity(there is no service builder) in my portlet but i want to select or insert data in any table of database.
How can i do that?
How can i do that?
Subhash Pavuskar, módosítva 11 év-val korábban
RE: How can Query in database table whitout service builder?
Regular Member Bejegyzések: 234 Csatlakozás dátuma: 2012.03.13. Legújabb bejegyzések
Hi habib zare ,
You can do this by manual JDBC connection!! but its having lots of disadvantage !!
For Ex:
You can do this by manual JDBC connection!! but its having lots of disadvantage !!
For Ex:
<%@ page import ="java.sql.*" %>
<%@ page import ="javax.sql.*" %>
<%
String userid=request.getParameter("user");
session.putValue("userid",userid);
String pwd=request.getParameter("pwd");
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
Statement st= con.createStatement();
ResultSet rs=st.executeQuery("select * from users where user_id='"+userid+"'");
if(rs.next())
{
if(rs.getString(2).equals(pwd))
{
out.println("welcome"+userid);
}
else
{
out.println("Invalid password try again");
}
}
%>
habib zare, módosítva 11 év-val korábban
RE: How can Query in database table whitout service builder?
Junior Member Bejegyzések: 58 Csatlakozás dátuma: 2012.10.28. Legújabb bejegyzések
Thanks Subhash.
Can I do this by custom sql or dynamic query?
Can I do this by custom sql or dynamic query?
Subhash Pavuskar, módosítva 11 év-val korábban
RE: How can Query in database table whitout service builder?
Regular Member Bejegyzések: 234 Csatlakozás dátuma: 2012.03.13. Legújabb bejegyzésekHabib Zare:
Can I do this by custom sql or dynamic query?
I dint get your question !!
Habib Zare, módosítva 11 év-val korábban
RE: How can Query in database table whitout service builder?
Junior Member Bejegyzések: 58 Csatlakozás dátuma: 2012.10.28. Legújabb bejegyzésekSubhash Pavuskar:
Habib Zare:
Can I do this by custom sql or dynamic query?
I dint get your question !!
Can i insert to extisting table by custom-sql or dynamic query?(There is no service.)
Subhash Pavuskar, módosítva 11 év-val korábban
RE: How can Query in database table whitout service builder?
Regular Member Bejegyzések: 234 Csatlakozás dátuma: 2012.03.13. Legújabb bejegyzések
Hi
Pls have a look on this thread !!
http://www.liferay.com/community/forums/-/message_boards/message/12569596
Pls have a look on this thread !!
http://www.liferay.com/community/forums/-/message_boards/message/12569596
Hitoshi Ozawa, módosítva 11 év-val korábban
RE: How can Query in database table whitout service builder?
Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
You can just a method in Impl class corresponding to the database table class. If it's a liferay table, you probably won't have problem.
Example
UserLocalServiceImpl.dynamicQuery()
Example
UserLocalServiceImpl.dynamicQuery()
Habib Zare, módosítva 11 év-val korábban
RE: How can Query in database table whitout service builder?
Junior Member Bejegyzések: 58 Csatlakozás dátuma: 2012.10.28. Legújabb bejegyzések
Thanks Hitoshi.
but I added the table in database. table is not liferay table.
but I added the table in database. table is not liferay table.
Hitoshi Ozawa, módosítva 11 év-val korábban
RE: How can Query in database table whitout service builder?
Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzésekbut I added the table in database. table is not liferay table.
And you don't want to use service builder. So did you code dynamicquery and customquery methods yourself? If you did, you can just call that.
Habib Zare, módosítva 11 év-val korábban
RE: How can Query in database table whitout service builder?
Junior Member Bejegyzések: 58 Csatlakozás dátuma: 2012.10.28. Legújabb bejegyzések
Yes Hitoshi.
I can call customquery in my finderimpl class when i use servicebuilder like :
but if there is no servicebuilder ,i can`t.
i can`t use openSession().
i want any example to learn.
thx.
I can call customquery in my finderimpl class when i use servicebuilder like :
public Object findByName( String name)
{
Session session = null;
session = openSession();
String sql = CustomSQLUtil.get("com.habib.findByName");
SQLQuery q = session.createSQLQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
return q.list(true);
}
but if there is no servicebuilder ,i can`t.
i can`t use openSession().
i want any example to learn.
thx.
Hitoshi Ozawa, módosítva 11 év-val korábban
RE: How can Query in database table whitout service builder?
Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzésekbut if there is no servicebuilder ,i can`t.
i can`t use openSession().
That's simply because you didn't create a method. Create it.
How else did you think you can call on a function without generating it or creating it yourself.