Implemention of JAAS+servlet+jboss+sql database

Hi,
I am trying to implement JAAS for login module using code and CallbackHandler( ie lc = logincontext(...).), but i got a sample code which is used for commandline execution, but i need to implement in web application, what all are the files that i need to configure to implement JAAS in web application?, so that i can check the user name and password which is entered by the user against the value that inside my sql database. it would be appreciated if anyone send some sample code to start work on JAAS.
Regards
kumar

Kumar,
i am trying to do the same thing, but i am having a slight problem, maybe between the two of us we can figure it out. here is what i have come up with so far:
1. edit web.xml to specifiy which directories and pages are secured and accessed only by specific user roles (Optional)
2. edit login-config.xml which is found in JBOSS_directory/server/default/conf or JBOSS_directory/server/all/conf depending on which version of the server you are using. you need to add the following to login-config.xml file, to include the JAAS DatabaseServerLoginModule, the configuration is as follows:
<application-policy name = "testDB"> <! -- this is the name of the secrurity policy which you refer to in jboss-web.xml
<authentication>
<login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule"
flag = "required">
<module-option name = "unauthenticatedIdentity">guest</module-option>
<module-option name = "dsJndiName">java:/testDB</module-option> <! -- this is the datasource the is used to connect to your database
<module-option name = "principalsQuery">SELECT password from Principals where PrincipalID =?</module-option>
<module-option name = "rolesQuery">SELECT Role, Rolegroup FROM roles WHERE principalid=?</module-option>
</login-module>
</authentication>
</application-policy>3. you edit jboss-web.xml with the following code
<jboss-web>
<security-domain>java:/jaas/testDB</security-domain>
<context-root>/testJBOSSsecurity</context-root>
</jboss-web>4. Create a Login Form with the action pointing to the servlet you will create in the next step
5. create the servlet that handles logging the user in
****loginservlet.java*****
import java.security.Principal;
import java.security.PrivilegedAction;
import java.util.Locale;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Set;
import javax.security.*;
import org.jboss.security.SimplePrincipal;
import org.jboss.security.auth.callback.SecurityAssociationHandler;
try {
SecurityAssociationHandler handler = new
SecurityAssociationHandler();
Principal user = new SimplePrincipal(request.getParameter("j_username"));
handler.setSecurityInfo(user, request.getParameter("j_password"));
LoginContext loginContext = new LoginContext("testDB",(CallbackHandler)handler);
loginContext.login();
Subject subject = loginContext.getSubject();
Set principals = subject.getPrincipals();
principals.add(user);
out.println(subject.toString());
//response.sendRedirect("securepage.java");
}6. create two database tables: one to hold the principalid (primary key) and password. this table is called pricipals. create another table to hold the user roles. call this table roles, and it has three fields. principalid as a primary key and a foreign key from the principals table, role and rolegroup
this is what i have so far, but it's not working, i have posted my problem in this link [http://forum.java.sun.com/thread.jspa?threadID=5293266|http://forum.java.sun.com/thread.jspa?threadID=5293266] as well an other forums since two nights ago, but so far no replies. so read the post and you will get a better picure and try it out, if you have luck wiith it, please let me know
Sam

Similar Messages

  • Complete configuration of JAAS with JBOSS using database

    JAAS Configuration
    1.     Database
         Create following table:
    a.     Principals table consists of usernames (PrincipalID) and their passwords.
    CREATE TABLE Principals (PrincipalID VARCHAR (64) PRIMARY KEY,
    Password VARCHAR (64))
    Insert data
    INSERT INTO Principals VALUES ('java', 'echoman')
    INSERT INTO Principals VALUES ('duke', 'javaman')     
    b.     Roles table consists of usernames (PrincipalID) and their Role and the
    RoleGroup they belong.
    CREATE TABLE Roles (PrincipalID VARCHAR (64), Role
    VARCHAR (64), RoleGroup VARCHAR (64))
    Insert data
    INSERT INTO Roles VALUES ('java', 'Echo', 'Roles')
    INSERT INTO Roles VALUES ('java', 'caller_java', 'CallerPrincipal')
    INSERT INTO Roles VALUES ('duke', 'Java', 'Roles')
    INSERT INTO Roles VALUES ('duke', 'Coder', 'Roles')
    INSERT INTO Roles VALUES ('duke', 'caller_duke', 'CallerPrincipal')
    INSERT INTO Roles VALUES ('duke', 'Echo', 'Roles')
    2.     login-config.xml
    This file is located in jboss-3.2.1\server\default\conf
    a.     add the following lines
                             <application-policy name="example2">
                                  <authentication>
                                       <login-module code="org.jboss.security.ClientLoginModule" flag="required">
                                  </login-module>
                             <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule"
                             flag="required">
                             <module-option name="managedConnectionFactoryName">
                        jboss.jca:service=LocalTxCM,name=SybaseDB
                                       </module-option>
                                       <module-option name="dsJndiName">
                                            java:/SybaseDB
                                       </module-option>
              <module-option name="principalsQuery">
              Select Password from Principals where PrincipalID =?
              </module-option>
                                       <module-option name="rolesQuery">
                                            Select Role 'Roles', RoleGroup 'RoleGroups' from Roles where                                              PrincipalID =?
                                       </module-option>
                             </login-module>
                        </authentication>
                   </application-policy>
    3.     jboss-web.xml
         Create a file jboss-web.xml and place the following code
              <?xml version="1.0" encoding="UTF-8"?>
              <jboss-web>
                   <security-domain>java:/jaas/example2</security-domain>
              </jboss-web>
    example2 is the name of the security domain which we specified in application policy of login-config.xml
    Copy this file in your applications WEB-INF folder
    4. auth.conf
         Create a file auth.conf and place it in jboss-3.2.1\client.
    client-login
              org.jboss.security.ClientLoginModule required;
    example2
              org.jboss.security.ClientLoginModule required;
    org.jboss.security.auth.spi.DatabaseServerLoginModule required;
    5.     auth.conf
         Create another auth.conf and place it in jboss-3.2.1\server\default\conf
    // The JBoss server side JAAS login config file for the examples
    client-login
              org.jboss.security.ClientLoginModule required;
    example2
              org.jboss.security.ClientLoginModule required;
         org.jboss.security.auth.spi.DatabaseServerLoginModule
    required
              dsJndiName="java:/SybaseDB"
    principalsQuery="Select Password from Principals where PrincipalID =?"
    rolesQuery="Select Role 'Roles', RoleGroup 'RoleGroups' from Roles where PrincipalID =?"
    5.     jndi
         Path jboss-3.2.1\server\default\conf
         java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
    # Do NOT uncomment this line as it causes in VM calls to go over
    # RMI!
    java.naming.provider.url=localhost:1099
    #localhost
    6.     web.xml
    Place the following code in your web.xml.(Change it according to your application requirements).
         <security-constraint>
              <web-resource-collection>
                   <web-resource-name>action</web-resource-name>
                   <description>Declarative security tests</description>
                   <url-pattern>*.do</url-pattern>
                   <http-method>HEAD</http-method>
                   <http-method>GET</http-method>
                   <http-method>POST</http-method>
                   <http-method>PUT</http-method>
                   <http-method>DELETE</http-method>
              </web-resource-collection>
              // the role which can access these resources
              <auth-constraint>
                   <role-name>Echo</role-name>
                   <!--<role-name>Java</role-name>-->
              </auth-constraint>
              <user-data-constraint>
                   <description>no description</description>
                   <transport-guarantee>NONE</transport-guarantee>
              </user-data-constraint>
         </security-constraint>
              //the login page in case of Basic authentication
         <!--<login-config>
              <auth-method>BASIC</auth-method>
              <realm-name>JAAS Tutorial Servlets</realm-name>
         </login-config>-->
         //the login page in case of form based authentication
         <login-config>
              <auth-method>FORM</auth-method>
              <form-login-config>
                   <form-login-page>/logon.do</form-login-page> //path to login page
                   <form-error-page>/logoff.do</form-error-page> //path in case login fails
              </form-login-config>
         </login-config>
         <security-role>
              <description>A user allowed to invoke echo methods</description>
              <role-name>Echo</role-name>
         </security-role>
         <!--
         <security-role>
              <description>A user allowed to invoke echo methods</description>
         <role-name>Java</role-name>
         </security-role>
         -->
    7.     login.jsp
    <%@ page contentType="text/html; charset=UTF-8" %>
    <%@ page language="java" %>
    <html >
    <HEAD>
    <TITLE></TITLE>
    <!-- To prevent caching -->
    <%
    response.setHeader("Cache-Control","no-cache"); // HTTP 1.1
    response.setHeader("Pragma","no-cache"); // HTTP 1.0
    response.setDateHeader ("Expires", -1); // Prevents caching at the proxy server
    %>
    <SCRIPT>
    function submitForm() {
    var frm = document. logonForm;
    // Check if all the required fields have been entered by the user before
    // submitting the form
    if( frm.j_username.value == "" ) {
    alert("blank");
    frm.j_username.focus();
    return ;
    if( frm.j_password.value == "" ) {   
    alert("blank");
    frm.j_password.focus();
    return ;
    frm.submit();
    </SCRIPT>
    </HEAD>
    <BODY>
    <FORM name="logonForm" action="logon.do" METHOD=POST>
    <TABLE width="100%" border="0" cellspacing="0" cellpadding=
    "1" bgcolor="white">
    <TABLE width="100%" border="0" cellspacing=
    "0" cellpadding="5">
    <TR align="center">
    <TD align="right" class="Prompt"></TD>
    <TD align="left">
    <INPUT type="text" name="j_username" maxlength=20>
    </TD>
    </TR>
    <TR align="center">
    <TD align="right" class="Prompt"> </TD>
    <TD align="left">
    <INPUT type="password"
    name="j_password" maxlength=20 >
    <BR>
    <TR align="center">
    <TD align="right" class="Prompt"> </TD>
              <TD align="left">     
         <input type="submit" onclick="javascript:submitForm();" value="Login">
    </TD>
    </TR>
    </TABLE>
    </FORM>
    </BODY>
    </html>
    8. Your action class should contain the following code
         a. Pacakages to be imported
    import java.util.Set;
    import javax.security.auth.Subject;
    import javax.security.auth.callback.CallbackHandler;
    import javax.security.auth.login.LoginContext;
    import javax.security.auth.login.LoginException;
    import org.jboss.security.SimplePrincipal;
    import org.jboss.security.auth.callback.SecurityAssociationHandler;
         try
    SecurityAssociationHandler handler = new
    SecurityAssociationHandler();
    user = new SimplePrincipal(username);
    handler.setSecurityInfo(user, password.toCharArray());
    LoginContext loginContext = new LoginContext("example2",
    (CallbackHandler)handler);
    loginContext.login();
    Subject subject = loginContext.getSubject();
    Set principals = subject.getPrincipals();
    principals.add(user);
    }catch(LoginException e)
    { errors.add("loginerror", new ActionError("Wrong Username or  Password")); saveErrors(request, errors);
    //other login related code

    Hi,
    Can I just first of all say how useful I found this article.
    It has been a great help in explaining what I need to do.
    I just had a couple of questions about the details...
    1) The jndi.properties file appears to be much the same except for the line...
    java.naming.provider.url=jnp://localhost:1099
    Are you saying we need to add that line to the jndi.properties or else all calls will go through rmi ?
    2) Should the line be java.naming.provider.url=jnp://localhost:1099 or url=localhost:1099 ?
    Thanks again for the article
    Dave

  • Using Non-Oracle Implementations of JAAS in JDeveloper TP2

    Hi,
    We have developed an application using JDeveloper TP2. We need to secure the web application using JAAS. However, we are not using ADF as we met into some browser incompatibility problems and as such the project's Technology Scope are as follows:
    HTML
    JSP
    JSP and Servlets
    JAVA
    XML
    We are using a Native Datasource for handling database connections.
    We would like to know how we can implement a CustomLoginModule without using oracle (ADF) implementation of JAAS and preferably without using the ADF Security Wizard as it does not work within our application ( i suppose this is because we are not using ADF)
    Cheers,
    Jankee Yogesh

    Duplicate of Re: Using Non-Oracle Implementations of JAAS in JDeveloper TP2

  • Applet connecting to MS SQL Database (Remote DataSourse)

    Hello,
    I started by building my interface to a Database within an Application. I am not to the point where I am ready to make it an applet but want to get some tips when the time comes very soon.
    First of all what security issues do I have to deal with to let the applet connect to the database?
    Second I currently created a local Datasource via ODBC call JavaDB and linked it to my MS SQL Database.
    QUESTION
    How do I link to the with a remote Datasource so that the local machine does not have to worry about the datasource.
    Lastly can I use the "sun.jdbc.odbc.JdbcOdbcDriver" in an applet. I sure hope so...
    Then the part of my code that connected to the database was this:
    private void initDB(){
    String url = "jdbc:ODBC:JavaDB";
    Connection con;
    String query = "select * from COFFEES";
    Statement stmt;
    try {
    //Class.forName("myDriver.ClassName");
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    try {
    con = DriverManager.getConnection(url, DBADM, DBPWD);
    stmt = con.createStatement();                                   
    ResultSet rs = stmt.executeQuery(query);
    ResultSetMetaData rsmd = rs.getMetaData();
    System.out.println("");
    int numberOfColumns = rsmd.getColumnCount();
    for (int i = 1; i <= numberOfColumns; i++) {
         if (i > 1) System.out.print(", ");
         String columnName = rsmd.getColumnName(i);
         System.out.print(columnName);
    System.out.println("");
    while (rs.next()) {
         for (int i = 1; i <= numberOfColumns; i++) {
         if (i > 1) System.out.print(", ");
         String columnValue = rs.getString(i);
         System.out.print(columnValue);
         System.out.println("");     
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.print("SQLException: ");
    System.err.println(ex.getMessage());
    Thanks,
    Kenny

    Kenny,
    As no one has replied, I've managed to implement a database that uses applets.
    Firstly, one needs to obtain a JSP server (apache tomcat is free and can be configured into a IIS 4 server).
    Secondly, write all the DB connection stuff within a jsp page (ex.) "builders.jsp"
    <%@ page import="java.sql.*" %>
    <%!
    protected String driver="sun.jdbc.odbc.JdbcOdbcDriver";
    protected String url="jdbc:odbc:PhotoDBase";
    protected String userid=null;
    protected String passwd=null;
    %>
    <html><head><title>Builder Example</title></head><body>
    <%!
    public static String GET_BUILDER_QUERY =
    "SELECT * FROM BuilderInfo WHERE BuilderID =?";
    %>
    <%
    String bID = "24"; //normally this would use
    //request.Parameter("bID");
    //in order to pull up a specific
    //record. In this test case it is
    //hard coded to pull only builder #24
    %>
    <%
    Class.forName(driver);
    Connection conn = DriverManager.getConnection(url, userid, passwd);
    PreparedStatement stmt = conn.prepareStatement(GET_BUILDER_QUERY);
    stmt.setString(1, bID);
    ResultSet rs = stmt.executeQuery();
    rs.next();
         String buildID = rs.getString("BuilderID");
         String bName = rs.getString("BuilderName");
         String bAddress = rs.getString("Address");
         String bCity = rs.getString("City");
         String bState = rs.getString("State");
         String bZip = rs.getString("Zip");
         String bCName = rs.getString("ContactName");
         String bCLast = rs.getString("ContactLast");
         String bPhone = rs.getString("Phone");
         String bFax = rs.getString("Fax");
         String bMobile = rs.getString("Pager/Cell");
    rs.close();
    stmt.close();
    if (bName == null)
         bName = "No Builder";
    if (bAddress == null)
         bAddress = "N/A";
    if (bCity == null)
         bCity = "N/A";
    if (bState == null)
         bState = "N/A";
    if (bZip == null)
         bZip = "N/A";
    if (bCName == null)
    bCName = "N/A";
    if (bCLast == null)
         bCLast = "N/A";
    if (bPhone == null)
         bPhone = "N/A";
    if (bFax == null)
    bFax = "N/A";
    if (bMobile == null)
    bMobile = "N/A";
    %>
    <p>Builder: <%= bName%> BuilderID #: <%= buildID%>
    <br>Contact: <%= bCName%> <%= bCLast%>
    <br>Address: <%= bAddress%>
    <br><%= bCity%>, <%= bState%> <%= bZip%>
    <br>Phone: <%= bPhone%>
    <br>Fax: <%= bFax%>
    <br>Mobile: <%= bMobile%>
    <p><applet code="Build.class" width="600" height="300">
    <param name=buildID value=<%= buildID%>>
    <param name=bName value="<%= bName%>">
    <param name=bAddress value="<%= bAddress%>">
    <param name=bCity value="<%= bCity%>">
    <param name=bState value="<%= bState%>">
    <param name=bZip value="<%= bZip%>">
    <param name=bCName value="<%= bCName%>">
    <param name=bCLast value="<%= bCLast%>">
    <param name=bPhone value="<%= bPhone%>">
    <param name=bFax value="<%= bFax%>">
    <param name=bMobile value="<%= bMobile%>">
    </applet>
    </body>
    </html>
    The jsp gets the data from the DB based on the parameter bID which would be passed to it via a search or input page with various error checking included.
    The applet then recieves its data via parameters. (Build.class has been shortened here to show you the meat and potatoes of the whole deal)
    //<applet code="Build.class" width="600" height="300"></applet>
    import java.awt.*;
    import java.awt.Event;
    import java.applet.Applet;
    import java.io.*;
    public class Build extends java.applet.Applet {
    protected Panel search ;
    protected TextField Nametxt ;
    protected TextField Loctxt ;
    protected TextField Citytxt ;
    protected TextField Statetxt ;
    protected TextField Ziptxt ;
    protected TextField CNametxt ;
    protected TextField CLasttxt ;
    protected TextField Phonetxt ;
    protected TextField Faxtxt ;
    protected TextField Celltxt ;
    public Build(){
    super();
    search = new Panel();
    Nametxt = new TextField();
    Loctxt = new TextField();
    Citytxt = new TextField();
    Statetxt = new TextField();
    Ziptxt = new TextField();
    CNametxt = new TextField();
    CLasttxt = new TextField();
    Phonetxt = new TextField();
    Faxtxt = new TextField();
    Celltxt = new TextField();}
    public void init(){
         BorderLayout bl = new BorderLayout();
         setLayout(bl);
         add(search, "Center");
         setBackground(Color.white);
         String buildID = getParameter("buildID");
         String bName = getParameter("bName");
         String bAddress = getParameter("bAddress");
         String bCity = getParameter("bCity");
         String bState = getParameter("bState");
         String bZip = getParameter("bZip");
         String bCName = getParameter("bCName");
         String bCLast = getParameter("bCLast");
         String bPhone = getParameter("bPhone");
         String bFax = getParameter("bFax");
         String bMobile = getParameter("bMobile");
    Nametxt.setText(bName);
    Loctxt.setText(bAddress);
    Citytxt.setText(bCity);
    Statetxt.setText(bState);
    Ziptxt.setText(bZip);
    CNametxt.setText(bCName);
    CLasttxt.setText(bCLast);
    Phonetxt.setText(bPhone);
    Faxtxt.setText(bFax);
    Celltxt.setText(bMobile);
    Hope this will aid you in yours and anyone elses endevours.
    James <[email protected]>

  • Applet / SQL Database communication

    I am developing an applet that needs to connect to a SQL Database to keep track of a variety of information. I am running into some errors when I try to connect to the database.
    Can anyone tell me the best way for an applet to connect to a SQL database without editing the client's policy file to give permission?
    Any help with this matter would be much appreciated.
    Thanks.

    I am developing an applet that needs to connect to a
    SQL Database to keep track of a variety of
    information. I am running into some errors when I
    try to connect to the database.
    Can anyone tell me the best way for an applet to
    connect to a SQL database without editing the
    client's policy file to give permission?
    Any help with this matter would be much appreciated.
    Thanks.The best way to communicate to the database from an applet is through a servlet. But if you seriously want anybody to decompile your applet code and really fry your db its upto you. I wouldnot communicate directly from an applet to a db its not worthwhile

  • How to connect and query the sql database in mobile application

    Hello,
    Can any one say how to connect the sql database from the j2me application.
    I have got some info that only through servlet or jsp only we can connect the database and from their we should get the info or query in mobile application.
    Is it true? and can i have any sample codes or white paper or guildlines.
    It would be more useful form my project.
    Thanks in advance.
    regards,
    sara

    Hi David,
    According to your description, when you add Windows Azure Mobile Services to a Window Phone 8 app, then store app data in the new mobile service. I recommend you post the related question on the Windows Azure Mobile Services Forums at
    http://social.msdn.microsoft.com/Forums/en-US/home?forum=azuremobile .It is appropriate and more experts will assist you.
    In addition, there are the details about creating a Windows Phone app connected to your mobile service.
    http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started-wp8/
    http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started-with-data-wp8/
    Thanks,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Error when save date in SQL database

    Hi all,
    I try to save a date in to a sql database, but when I run my program I get following error:
    Invalid object 11/21/05 9:32 AM of type java.sql.Date assigned to host variable 3.
    In my database table I have a fields date (type Data)en time type(Time).
    this is the source:
         public void createTitle(int title_id, String description, String user)
              throws SQLException {
              // TODO Auto-generated method stub
              Date date = new Date();
              String dateFormat = "YYYY-MM-DD";
              String timeFormat = "HH:mm:ss";
              SimpleDateFormat ddf = new SimpleDateFormat(dateFormat);
              SimpleDateFormat tdf = new SimpleDateFormat(timeFormat);
              String det = ddf.format(date);
              String creationTime = tdf.format(date);
              PreparedStatement newTitle = conn.prepareStatement("INSERT INTO BE_TITLE (TITLE_ID, DESCRIPTION, DATE_CREATE, TIME_CREATE, USER_CREATE) VALUES (?,?,?,?,?)");     
              try{
                   newTitle.setInt(1,title_id);
                   newTitle.setString(2,description);
                   newTitle.setDate(3, new java.sql.Date(date.getTime()));
                   newTitle.setTime(4, new java.sql.Time(date.getTime()));
                   newTitle.setString(5, user);
                   newTitle.executeUpdate();
              }finally{
                   newTitle.close();
    Can someone give me a solution for this error
    Richard

    Hi Richard,
    in your application, you atempt to insert a java.sql.Date value into a DATE column, which has non-zero time-components. Open SQL rejects such an atempt.
    Please allow me to quote from the OSS message (452727 2004), which Detlev refers to in his quote:
    <i>
    about one year ago, we had a very lengthy discussion on this issue - not only internally at SAP but also with Jonathan Bruce, the specification lead for JBDC at Sun.                                                                               
    We have the following dillema:                                                                               
    The javadoc of the constructor java.sql.Date(long) states:                                                                               
    "If the given milliseconds value contains time information, the driver will set the time components to the time in the default time zone (the time zone of the Java virtual machine running the application) that corresponds to zero GMT."                                                                               
    With Jonathan Bruce, we tried to clarify when this normalization should take place.                                                               
    1) Source code inspection shows that it is not the class java.sql.Date the performs the normalization.                                                                               
    2) The Javadoc states that the JDBC driver should perform the             
    normalization. If it is the driver, more open questions arrise:                                                                               
    a) When shall the normalization be performed?                             
       - if a setDate method is invoked?                                      
       - only for INSERT and update statements or also for all other parameters?                                                               
       - shall the getDate method perform the normalization?                  
       - what about set/getObject?                                            
       - the java Docs of set/getDate don't tell anything about normalization.                                                            
       - according to which time zone shall the value be normalized?          
         - UTC                                                                
         - vm time zone?                                                      
         - database time zone?                                                                               
    3) If an automatic normalization is performed, data will be modified upon insertion (or extraction) from the database. This means that we cannot quarantee if we insert and Date object retrieve it again that the two objects will be equal.
    In the discussion with Jonathan, we couldn't clarify the issue. However, Jonathan promised that the JDK should be modified in such a way that the JDK is responsible for the normalization. (So far such a change has not been done).                                                                               
    In order to be on the safe side, SAP chose that Open SQL should reject any Date values that are not normalized. This is what we have          
    implemented and documented. I agree, that in this repect, Open SQL is stricter than the JDBC standard demands.                                                                               
    To help the application with the task to normalize a Date (and Time) object, we offer the helper class                                      
    com.sap.sql.DateTimeNormalizer which you find in opensql.jar.                                                                               
    To come to a conclusion, the bevavoir you observed is from our side not a bug of Open SQL but a feature. Please use DateTimeNormalizer to normalize Date objects appropriately.                                  
    </i>
    I hope, you can follow our reasoning.
    Best regards,
    Adrian

  • JAAS and JBOSS

    I'm trying to use JAAS to log in a user on a JBOSS app, but am running into a problem. I'm able to successfully authenticate the user, and retrieve a Subject from my LoginContext. However, once that request is done (i.e. the browser displays the "log in complete" page), the application seems to forget that the user was logged in. How does JAAS and JBOSS keep track of the logged in user? Is this done by keeping a singleton of LoginContext around in some scope? Right now I'm creating a new instance of LoginContext, and using it to load a new instance of my CallbackHandler. Note, when I used JBOSS default form based authentication, it kept the user logged in. However, I can't use their default auth because I have some custom things I need to do.
    Thanks in advance for any help you provide.

    Hi,
    I tested this on OC4J for you and here - after setting jbo.security.enforce to Must, the user principal name and the roles are displayed.
    So there are three possibilities why you don't see things working
    - JBoss doesn't add the role principals to the Subject so they become available in the session
    - You attempt accessing this information in a prepareSession() override without enforcing authentication to happen for the root page - URL pattern = /
    - ADF BC security doesn't recognize the custom role principal
    After briefly reviewing the security implementation code, it seems that ADF BC security is dependent on Oracle JAZN for authorization.
    Frank

  • Authorization failed with JAAS in JBOSS

    Hi all,
    I write my own login module class (WusLdapLoginModule) for my web app. I can authenticate my user with username and password. But I failed in authorizing my user with roles.
    I believe that I missed something, please help me.
    My web application run on WinXP, Jboss 4.2.3 GA, OpenLdap 2.0.2.9
    Here is my login module class:
    package wus.identity.security;
    import java.io.IOException;
    import java.util.Map;
    import javax.security.auth.callback.Callback;
    import javax.security.auth.callback.CallbackHandler;
    import javax.security.auth.callback.NameCallback;
    import javax.security.auth.callback.PasswordCallback;
    import javax.security.auth.callback.UnsupportedCallbackException;
    import javax.security.auth.login.LoginException;
    import javax.security.auth.spi.LoginModule;
    import javax.security.auth.Subject;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import wus.identity.Role;
    import wus.identity.User;
    import wus.identity.dao.UserDAO;
    public class WusLdapLoginModule implements LoginModule
        //properties
        private Subject subject;
        private CallbackHandler callbackHandler;
        private Map<String,?> sharedStates;
        private Map<String,?> options;
        private boolean loginOk;
        private User m_user;
        //====== DAO ====================
        private UserDAO m_userDao = new UserDAO();
        private static final Log log = LogFactory.getLog(WusLdapLoginModule.class);
        @Override
        public boolean commit() throws LoginException
            int i;
            if(loginOk)
                if(!subject.getPrincipals().contains(this.m_user))
                    this.subject.getPrincipals().add(this.m_user);               
                    for(i=0;i<m_user.getRoles().size();i++)
                        this.subject.getPrincipals().add(m_user.getRoles().get(i));
                AuthenticatedUser.setAuthenticatedUser(m_user);
            return loginOk;
    }Here is my Role class
    package wus.identity;
    import java.io.Serializable;
    import java.security.Principal;
    public class Role implements Principal, Serializable
        private static final long serialVersionUID = 10797L;
        //Properties
        private String name;
        private String note;
        public Role()
            name = "";
        @Override
        public String getName()
            // TODO Auto-generated method stub
            return name;
        }Here is a part of web.xml:
    <security-constraint>
            <web-resource-collection>
                <web-resource-name>Secure Area</web-resource-name>
                <url-pattern>/sa/*</url-pattern>
                <http-method>GET</http-method>
                <http-method>POST</http-method>
            </web-resource-collection>
            <auth-constraint>
                <!-- <role-name>user</role-name>  -->
                <role-name>user</role-name>
            </auth-constraint>
        </security-constraint>
        <!-- end security constraints -->
        <!-- Example Login page - lists user names -->
        <login-config>
            <auth-method>FORM</auth-method>
            <form-login-config>
                <form-login-page>/ua/login-example.jsf</form-login-page>
                <form-error-page>/ua/login-example.jsf?error=true</form-error-page>
            </form-login-config>
        </login-config>
    <security-role>
            <role-name>admin</role-name>
        </security-role>
        <security-role>
            <role-name>user</role-name>
        </security-role>Thank in advance,
    Vu

    How is this question related to JSF?
    Try a forum devoted to JAAS or JBoss, depending on the root cause of the problem.

  • Generating next number from the SQL database using java

    Hi friends, I have a problem and need your help. I am working on a project about submitting claims form through the adobe PDF file and SQL database. I have problem working on a web service (written in java) that will generate the next Invoice Number from the SQL Database table. The field type for the column is text(var char). *Example: I first need to get into the table and search for the last Invoice number in the table and if the last invoice number in the table from the database is 3, i would want to generate the next number which is 4 and filled it up in the PDF file through web service that i am implementing. Can you all provide me some guidelines on how to implement this method in my web service?
    Thanks a lot. I need it by today. Hope someone can reply this as soon as possible.
    Lim89
    Edited by: LIM89 on Apr 2, 2008 7:10 PM

    far simpler to use a sequence generator, which most databases support.
    Suggested method to get the max value in the column is NOT secure, unless you lock the entire table for update before you do so, which is a severe performance penalty.

  • Performance/costs improvements from single SQL database to elastic scale

    Hi there!
    I already posted a previous question on whats the best way to setup a elastic scale architecture for our application(https://social.msdn.microsoft.com/Forums/azure/en-US/82fabac7-137b-46d6-a9f0-5e71e4bbc9eb/using-datadependent-routing-in-combination-with-membership-provider?forum=ssdsgetstarted).
    The next thing we need to know before we can implement elastic scale is if this is really going to help us with our performance and costs where we experiencing problems at the moment.
    Currently we have a single SQL database(p3 800 DTU's).
    We have run queries against our database which can calculate the number of DTU's we need to get good performance for that database.
    My questions are:
    1.When we implement elastic scale, can we really improve our performance and can this lead to saving costs on SQL databases?
    2. Is there maybe a way we can easily test this by running queries or setting up an environment  where we can see real differences in DTU's per Shard?
    Thanks!

    Hi Elmar,
    If you're already hitting performance limits with your P3 database, other than upgrading to the
    new V12 server for improved premium performance, that is the highest you can currently vertically scale.  Thus, it becomes advantageous to scale out to achieve better performance. 
    A small caveat, my answers below are really contingent upon your workload, query patterns, and sharding scheme.
    1.When we implement elastic scale, can we really improve our performance and can this lead to saving costs on SQL databases?
    Absolutely.  If you look at the table below, you can see the ~Cost per DTU/month. For a P3 you are paying $4.65/DTU/month.  If you were to scale out, with the same number of DTUs on an S2, for example, you'd achieve an 67% savings on
    cost for the same number of DTUs (800).  Please keep in mind that there are feature differences between Standard and Premium SKUs as well as total size (250GB vs 500GB) - these may or may not affect your application.
    **Please note that S3 above is the preview price (50% off).
    2. Is there maybe a way we can easily test this by running queries or setting up an environment  where we can see real differences in DTU's per Shard?
    The available DTUs per shard is a constant value.  In principle, 800 DTUs on one P3 database is equivalent in performance capacity of 100 DTUs on eight P1s.  The test you want to perform is a comparison between your scale-up
    solution versus a scale-out solution as perceived by both the database %DTUs consumed and the response time/throughput of your client application. 

  • Gateway elements and a SQL database connection

    Hello,
    I've been running into some rather strange activity with a process I created. My process has multiple gateway elements in it, to allow for multiple people to review and comment on a form throughout the process. I have run this process through on my own machine (this has your normal turnkey install on it), a Development server (set up on a VM), and a Production server (server 2003). Both the dev and production servers are set up to point to a SQL database. My turnkey install points to mysql that was installed as part of the turnkey installation. The process runs correctly on my turnkey install, but not on either of the two server installs. On the two servers where the process fails the process will do one of two things when it gets to a gateway. First it may run through all the branches as expected. Or it may decide not to run through a single or multiple branches. The process itself does not stall, nor does any single task show as stalled. When I review the process in the process management module in adminui, the process seems to be missing tasks when the process fails to execute properly. When I review the jBoss logs, I receive TransactionRolledbackLocalException errors and locking errors when LiveCycle tries to connect with the SQL database. It almost seems like something with the SQL database conncetion isn't allowing for the gateway to function properly. I only seem to be able to reproduce this with the servers that point to a SQL database. Has anyone else experienced anything like this? If so how did you resolve it?

    I am using a WAMP server and Flex3 and I have the same problem.
    I have a table called "reservations" in the MySQL database, with the following fields:
    reserv_id  - int(10)
    date - date
    begin_time - time
    end_time - time
    hours - int(10)
    price - int(10)
    court_id - int(10)
    user_id - int(10)
    When I "create application from database" I also get the message  "Table does not contain any columns.".
    why is it so? I was trying to find some solution in Internet, but didn't found nothing ..

  • Error trying to get LiveCycle ES up and running with JBoss/SQL Server

    I am having an error trying to get LiveCycle ES Trial up and running with JBOSS and SQL Server.  The LiveCycle ES and JBOSS engines are running on Windows Server 2003 SP #2 under VMWare Server with 2 vCPUs/1 GB vRAM.  The SQL Server database is SQL 2005 x86-64 with SP #2 on a separate server.<br /><br />I have carefully followed all of the instructions for setting up jboss, modifying all of the appropriate XML files, downloading the SQL JDBC drivers and putting it in the %JBOSS_HOME%\server\all\lib directory, etc.  I tried both the SQL JDBC 1.1 and 1.2 drivers and they both fail.<br /><br />The error I get is on startup of jboss using<br />cmd /c start /low run.bat -c all<br />(and yes I also just tried run.bat -c all)<br /><br />it runs along file until it gets here<br />2008-06-18 16:00:03,123 INFO  [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=IDP_DS' to JNDI name 'java:IDP_DS'<br />2008-06-18 16:00:03,123 INFO  [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=EDC_DS' to JNDI name 'java:EDC_DS'<br />2008-06-18 16:00:03,373 INFO  [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'<br />2008-06-18 16:00:03,373 INFO  [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=adobe_JmsQueueXA' to JNDI name 'java:adobe_JmsQueueXA'<br />2008-06-18 16:00:03,389 INFO  [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=adobe_JmsTopicXA' to JNDI name 'java:adobe_JmsTopicXA'<br />2008-06-18 16:00:03,482 INFO  [org.jboss.resource.connectionmanager.ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'<br />2008-06-18 16:00:03,514 WARN  [org.jboss.resource.connectionmanager.JBossManagedConnectionPool] Throwable while attempting to get a new connection: null<br />org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.microsoft.jdbc.sqlserver.SQLServerDriver; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: com.microsoft.jdbc.sqlserver.SQLServerDriver))<br />     at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnecti on(LocalManagedConnectionFactory.java:164)<br />[ lots more error scrolls ]<br /><br />this repeats multiple times<br /><br />I can see that it does acknowledge that I put the sqljdbc.jar file in the appropriate directory from the boot.log<br /><br /><snip><br />15:59:44,856 DEBUG [SARDeployer] deployed classes for file:/C:/jboss/server/all/lib/sqljdbc.jar<br /><snip><br /><br />please help!

    APJ<br />We ran into many issues setting up a very similar environment.  In the end we had to use a specially configured JBoss, supplied by Adobe, to make a connection with the SQL database.  Since you have SQL w/ SP2 on it, you will need the 1.2 driver for sure, but you may want to talk to Adobe support about obtaining the version of JBoss they supplied us with.  The Adobe Support Reference Number is: 1-52422366.<br /><br />Even with the alternate JBoss we had to perform the following steps to get the configuration right:<br /><br />1.     Install Livecycle from the installation DVD.  Follow the instructions for installing LiveCycle supplied by Adobe, including all pre-installation instructions.  Make sure NT service is installed with parameters, and dont run Configuration Manager.<br />2.     Rename %LIVECYCLE_INSTALL%\jboss to %LIVECYCLE_INSTALL%\jboss_orig<br />3.     Extract the zipped new, good instance of JBoss (supplied by Adobe)  to the %LIVECYCLE_INSTALL%\ folder  <br />4.     Go to the %LiveCycle_Home%\deploy folder and make a copy of the file adobeimport_SQLServer.jar file.  Rename the copy of the file to aadobeimport_SQLServer.jar.  There seems to be a bug in configuration manager that looks for a file with the extra  a appended to the beginning of the file name, where that file normally isnt there.  Make sure that the adobeimport_SQLServer.jar file is still in this folder as well.<br />5.     Edit the data source file (%JBOSS_HOME%\server\all\deploy\ adobe-ds.xml) to point to the correct database for the LiveCycle Server.<br />a.     Update the <connection-url>, <user-name>, and <password> tags with the correct database connection information.<br />b.     If BAM is to be used on the server (this should be done on the Production server) then delete both lines that state Remove this line, if BAM is used.<br />6.     Go to the login configuration file (%JBOSS_HOME%\server\all\conf\login-config.xml), and edit the section labeled <application-policy name = "MSSQLDbRealm">.<br />a.     Change the Principal, UserName, and Password options to point to the correct database.  These will be the same as what was changed in the adobe-ds.xml file from the step above.<br /><br />7.     Edit the system variables on the server.  Add to the Path variable %JBOSS_HOME%\bin, and add the variable JBOSS_HOME with the path to the JBoss folder on the server. (D:\Adobe\LiveCycle8\jboss  for example)<br />8.     From windows services start the JBoss for Adobe LiveCycle ES v8.0 service.  Review the JBoss server log (%JBOSS_HOME%\server\all\log\server.log) to verify that JBoss starts without throwing any exception errors (A document timeout exception is the only acceptable exception for starting the service).  <br />9.     Run the LiveCycle Configuration Manager (%LiveCycle_Home%\ConfigurationManager\bin\ConfigurationManager.bat).  <br />a.     Select to Not Upgrade fromLiveCycle 7.x.<br />b.     Check all boxes on the Solution Component Selection screen.<br />c.     For the Task Selection screen check all the boxes except for the Import LiveCycle ES Samples into LiveCycle ES if on the production server. <br />d.     Run through the rest of the configuration manager interface to setup the LiveCycle server with the new application server.  Follow the steps supplied by Adobe for this.<br />10.     Once configuration manager has completed, reboot the server, and verify that JBoss starts up again without any exceptions or errors (again a document timeout exception is an acceptable exception.  Look at the server log to verify this (%JBOSS_HOME%\server\all\log\server.log)).

  • Regarding SQL Database Initialization

    Hello All,
    I had an existing working version of LiveCycle on Server A which had two drives; A.1 and A.2. Do to space constraints we decided to move the Adobe LiveCycle ES2 folder from drive A.1 to A.2. We had not created anything so we werent worried about loosing any data. When it was installed on to drive A.1 it was runnning on the default MYSQL database that is created when you install using jboss turnkey. . But now we want to connect our jboss application to a SQL server database. I went ahead and walked through the documentation in order create the database and users. I also made the modicications to the XML files within jboss. The problem I am having is when I try to run the LiveCycle ES2 Database Initialization in the Configuration Manager, I get the following error:
    From LCM.log:
    [2013-04-22 15:29:51,196], SEVERE, Thread-14, com.adobe.livecycle.lcm.feature.bootstrap.BootstrapTask, Task failed
    com.adobe.livecycle.bootstrap.BootstrapException: ALC-TTN-109-000: Could not establish a valid connection to server: [Unexpected end of file from server]
              at com.adobe.livecycle.bootstrap.client.BootstrapClient.invoke(BootstrapClient.java:117)
              at com.adobe.livecycle.bootstrap.client.FetchTasksClient.fetchTasks(FetchTasksClient.java:68 )
              at com.adobe.livecycle.bootstrap.client.BootstrapManager.getTasks(BootstrapManager.java:147)
              at com.adobe.livecycle.lcm.feature.bootstrap.BootstrapTask$ActualTask.<init>(BootstrapTask.j ava:100)
              at com.adobe.livecycle.lcm.feature.bootstrap.BootstrapTask$1.construct(BootstrapTask.java:58 )
              at com.adobe.livecycle.lcm.core.tasks.SwingWorker$2.run(SwingWorker.java:114)
              at java.lang.Thread.run(Thread.java:619)
    Caused by: java.net.SocketException: Unexpected end of file from server
              at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:769)
              at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
              at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:766)
              at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
              at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1064)
              at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
              at com.adobe.livecycle.bootstrap.client.BootstrapClient.parseResponse(BootstrapClient.java:1 55)
              at com.adobe.livecycle.bootstrap.client.BootstrapClient.invoke(BootstrapClient.java:105)
              ... 6 more
    [2013-04-22 15:29:51,461], SEVERE, AWT-EventQueue-0, com.adobe.livecycle.lcm.feature.bootstrap.BootstrapDialog, Bootstrap exception
    com.adobe.livecycle.bootstrap.BootstrapException: ALC-TTN-109-000: Could not establish a valid connection to server: [Unexpected end of file from server]
              at com.adobe.livecycle.bootstrap.client.BootstrapClient.invoke(BootstrapClient.java:117)
              at com.adobe.livecycle.bootstrap.client.FetchTasksClient.fetchTasks(FetchTasksClient.java:68 )
              at com.adobe.livecycle.bootstrap.client.BootstrapManager.getTasks(BootstrapManager.java:147)
              at com.adobe.livecycle.lcm.feature.bootstrap.BootstrapTask$ActualTask.<init>(BootstrapTask.j ava:100)
              at com.adobe.livecycle.lcm.feature.bootstrap.BootstrapTask$1.construct(BootstrapTask.java:58 )
              at com.adobe.livecycle.lcm.core.tasks.SwingWorker$2.run(SwingWorker.java:114)
              at java.lang.Thread.run(Thread.java:619)
    Caused by: java.net.SocketException: Unexpected end of file from server
              at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:769)
              at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
              at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:766)
              at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
              at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1064)
              at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
              at com.adobe.livecycle.bootstrap.client.BootstrapClient.parseResponse(BootstrapClient.java:1 55)
              at com.adobe.livecycle.bootstrap.client.BootstrapClient.invoke(BootstrapClient.java:105)
              ... 6 more
    Are there other files that I need to configure in order to switch the application from the default MYSQL to the new SQL Database? And is there any way for me to test the connection to the database before I attempt to initialize it.
    Thanks in advance.

    First and foremost you cannot use the XMLs which are part of turnkey JBoss directly.
    You should discard adobe-ds.xml and mysql-ds.xml from <LiveCycle Root>/jboss/server/<server profile>/deploy and get hold of SQL Server specific adobe-ds.xml and mssql-ds.xml and then make necessary modifications w.r.t your SQL Server.
    In addition to this you would have to modify login-config.xml as well to add an entry of application policy for MSSQL DB.
    If you have performed all these steps and still issues are coming then the error could be because of any of the reasons mentioned below:
    The XMLs that you have configured
    The connection pools configured
    Missing database driver jar
    I would recommend the following:
    1) Make sure driver jar for SQL Server (most probably sqljdbc.jar) exists in <LiveCycle Root>/jboss/server/<server profile>/lib directory
    2) Ensure that you have modified the following XML files correctly:
    adobe-ds.xml and mssql-ds.xml inside <LiveCycle Root>/jboss/server/<server profile>/deploy directory
    login-config.xml inside <LiveCycle Root>/jboss/server/<server profile>/conf directory
    3) Ensure that you have removed mysql-ds.xml from the <LiveCycle Root>/jboss/server/<server profile>/deploy directory
    Try opening the XMLs in a browser to verify that they are modified correctly.
    You won't find an option to test the connection in LCM.
    Though you could try starting up your JBoss without any EARs and see if it is coming up without issues.

  • Image path not storing in sql database

    Hello,
    I have read here on the forum how to upload an image to server and store path in  your database, the image uploads correctly to the correct folder on my server but the image path does not get stored on my sql database (not local hosting). I receive the error: The file has been uploaded, and your information has been added to the directory. Column 'image' cannot be null.
    My database has the following columns:
    id
    datum
    image
    sectie
    My code is as follows:
    <?php require_once('Connections/dbTroch.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    mysql_select_db($database_dbTroch, $dbTroch);
    $query_rs_aanbod = "SELECT * FROM tblSlideshow ORDER BY id ASC";
    $rs_aanbod = mysql_query($query_rs_aanbod, $dbTroch) or die(mysql_error());
    $row_rs_aanbod = mysql_fetch_assoc($rs_aanbod);
    $totalRows_rs_aanbod = mysql_num_rows($rs_aanbod);
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    $target = "images/slides/";  //This is the directory where images will be saved// 
    $target = $target . basename( $_FILES['image']['name']); //change the image and name to whatever your database fields are called//
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add-photos-aanbod")) {
      $insertSQL = sprintf("INSERT INTO tblSlideshow (image, sectie) VALUES (%s, %s)",
                           GetSQLValueString($_POST['file'], "text"),
                           GetSQLValueString($_FILES['image']['name'], "text"));
    //This code writes the photo to the server//
    if(move_uploaded_file($_FILES['image']['tmp_name'], $target))
    //And confirms it has worked//
    echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
    else {
    //Gives error if not correct//
    echo "Sorry, there was a problem uploading your file.";
      mysql_select_db($database_dbTroch, $dbTroch);
      $Result1 = mysql_query($insertSQL, $dbTroch) or die(mysql_error());
    ?>
    <!doctype html>
    <html>
    <meta charset="utf-8" />
      <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Troch Project Solutions - Admin - Toevoegen</title>
      <link rel="stylesheet" href="css/foundation.css" />
      <link rel="stylesheet" href="css/layout.css" />
      <!-- Fonts
      ================================================== -->
      <script type="text/javascript" src="//use.typekit.net/vob8gxg.js"></script>
      <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
      <!-- jQuery
      ================================================== -->
      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
      <script src="js/vendor/modernizr.js"></script>
    </head>
    <body>
        <div class="row">
          <div class="large-8 medium-8 small-8 large-centered medium-centered small-centered columns intro">
              <h2 class="subheader text-center">Admin</h2>
              <p><a>Log uit</a></p>
              <p><a href="admin.php">Terug naar Admin menu</a>
              <h4>image toevoegen naar aanbod slideshows:</h4>
              <form action="<?php echo $row_rs_aanbod['']; ?>" method="POST" name="add-photos-aanbod" id="add-photos-aanbod" enctype="multipart/form-data">
              <table>
                    <tbody>
                         <tr>
                              <td><label for="image">Kies foto:</label></td>
                              <td><input name="image" type="file" id="image" value="<?php echo $row_rs_aanbod['image']; ?>" /></td>
                        <tr>
                              <td>Sectie:</td>
                              <td><select name="sectie" id="sectie" option value="sectie">
                                <?php
    do { 
    ?>
                                <option value="<?php echo $row_rs_aanbod['sectie']?>"><?php echo $row_rs_aanbod['sectie']?></option>
                                <?php
    } while ($row_rs_aanbod = mysql_fetch_assoc($rs_aanbod));
      $rows = mysql_num_rows($rs_aanbod);
      if($rows > 0) {
          mysql_data_seek($rs_aanbod, 0);
          $row_rs_aanbod = mysql_fetch_assoc($rs_aanbod);
    ?>
                              </select></td> 
                        </tr>
                        <tr>
                            <td><input type="Submit" name="Add" id="add" value="Toevoegen" /></td>
                        </tr>
                </tbody>
            </table>
            <input type="hidden" name="MM_insert" value="add-photos-aanbod" />
        </form>
          </div><!-- end large-8 -->
        </div><!-- end row -->
    <script src="js/vendor/jquery.js"></script>
    <script src="/js/vendor/fastclick.js"></script>
    <script src="js/foundation.min.js"></script>
    <script>
                $(document).foundation();
            </script>
    </body>
    </html>
    <?php
    mysql_free_result($rs_aanbod);
    ?>
    I cannot work out what is wrong and I would appreciate any help on this. Thanks

    Your form field and array variable names do not match
    <td><input name="image" type="file" id="image" value="<?php echo $row_rs_aanbod['image']; ?>" /></td>
    GetSQLValueString($_POST['file'], "text"),

Maybe you are looking for

  • How do I edit a PDF with PDF Pack?

    how do i edit a pdf pack?

  • Import into photoshop as layered smart objects

    is there a way to import images into mulitiple images into photoshop as smart objects from bridge? Thanks

  • Notification objects entry problem

    Dear all, my client needs to enter multiple functional locations and equipment to the pm notification. is it possible and in which tab? i know similar tab in order but can not find in notification... thanks

  • Bright tiny specks in windows

    Little bright specks appear in windows. Mostly while using Adobe Photoshop CS (but I saw this in a Safari browser window once, too) while editing images, I see tiny, pixel-sized, dots/specks, bright green usually. There can be anywhere from 1 of them

  • How to update the foreign key in a 1-to-many relation ?

    I have Product mapped to Channel as 1-1, and Channel mapped to Product as 1-M. Product has a nullable channel_id_fk as a foreign key to Channel, (so one can optionally specify or change the channel of a specific product). Starting with a specific pro