Configure the JNDI DataSource in Tomcat by adding a declaration for your resource to your context.xml.
<Context>
<Resourcename="jdbc/dbname" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/dbname?autoReconnect=true"/>
Context>
web.xml configuration
<web-appxmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<description>MySQL Test Appdescription>
When deploying a application that used ClientDataSet, you may want to distribute the Midas.dll. If your don't want to do so, you can also compile it into your exe.
program Project1;
uses MidasLib, Forms, Unit1 in'Unit1.pas'{Form1};
{$R *.res}
begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end.
Then here is the form startup and close. PrinterIndex is just a global variable.
procedure TForm1.FormCreate(Sender: TObject); var IniFile : TIniFile; begin IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'configuration.ini'); // Read the value from the ini file PrinterIndex := IniFile.ReadInteger('Printer','Index',0); IniFile.Free; end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); var IniFile : TIniFile; begin IniFile := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'configuration.ini'); // Save the value into the ini file IniFile.WriteInteger('Printer','Index',PrinterIndex); IniFile.Free; end;
So in your application you can do it this:
procedure TForm1.Button1Click(Sender: TObject); begin // Change current printer index to the value we get from the ini file. Printer.PrinterIndex := PrinterIndex; ShowMessage(IntToStr(Printer.PrinterIndex));
// Open the dialog PrinterSetupDialog1.Execute;
// Set new value to the PrinterIndex variable. ShowMessage(IntToStr(Printer.PrinterIndex)); PrinterIndex := Printer.PrinterIndex; ... ...