Friday, May 31, 2013

Adding modules to SageFrame V2.1

Adding Modules to the Sage Frame

Steps:
1. In visual studio, Solution Explorer Section, Goto Library -> Modules and Add the your existing Project (Class library project)
                 ----- Change the connection string to that of sageFrame which is located at connectionstring.config file.
                 ---- Build your Project.

2. Goto SageFrame in Solution Explorer -> Modules and Add a New Folder in the modules..Name it as you like(e.g.myModule ) and add the View/Control/Setting File. (eg. SampleModuleView.ascx and SampleModuleView.cs).
     Open the SampleModuleView.cs file  in the view/controller file and add a library 'using SageFrame.Web;' and inherit your main class  from :BaseUserControl

3. As you build your project in Step1 ..now Add a Reference to that project.

4. Build the Whole Solution and Debug.

5. Once SageFrame is opened in the browser, login using the username: superuser and password: superuser
6. Click on dashboard on the left top panel of the sageframe
7. Click on Modules in C-Panel, Create a new module -> Opens Modules Management window ->Select      Module Folder from the drop down list as you named (myModule) in the Sageframe.
8. Set package name as you would like to display the module as  and set key and title as you like, set 'Type= View' in the Module Control Setting and Save Module.
9. Search the module name and drag the module to the part you would like to place.

Saturday, March 23, 2013

JDBC connection to the MySQL database with wamp in Eclipse

Java programming with JDBC connection with MySQL from the IDE Eclipse.

Ptograms necessary:
                Eclipse
                Wamp

We are using wamp to install the MySQL required to execute the queries.

Furthermore we require JDBC connector to connect to the MySQL database. Follow the link and download the connector (Connector/J) from the MySQL site: http://dev.mysql.com/downloads/connector/j/

Open eclipse IDE. 
Create a Java Project.
 Insert a class in the default package. 
Right click the project and go to Build Path  → Configure Build Path → Java Build Path → Libraries → Add External JARs →  select the conector.jar file from the location where you saved the file after downloading.

Start the MySQL service from the WampServer.

Write the java program to make connection to the database.



import java.sql.*;

public class mysqltest {
public static void main(String[] args) throws Exception
{
//main class
Class.forName("com.mysql.jdbc.Driver");
//load the jdbc driver class
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/ecommerce","root","");/* red colored part has to be as per your database*/
/*make connection with the database(db name ecommerce, user is root and password is not set in my case put yours in those places with password if you have set password for the database*/
PreparedStatement statement = con.prepareStatement("Select * from products");
/*sql structure to select instances from the table*/
ResultSet result = statement.executeQuery();
/*execution of the database query*/ 
while(result.next()){
System.out.println(result.getString(1) +"\t"+ result.getString(2)+ "\t" + result.getString(3)+ "\t" + result.getString(4));
/*print the result with three attributes from the table 'products in my case' */
}
}
}