Is there any R function to convert grey scale image to binary image. There is one to convert from RGB to Grey but I want to convert Grey to Binary.
Monday, April 23, 2012
ZendFramework, using same variable twice causing null value
Hi I have a application where I have a list of clubs once the club is clicked it goes to a description page of this club by passing the variable "club_id" and then getting the information for that specific club. On this page is a comments box, at the moment If I click the comment button I get the data I need in the comments box but then when trying to redirect to the index page I get the error below:
Error -> http://pastebin.com/VscHSGXF
clubDescriptionController:
public function indexAction()
{
$this->authoriseUser();
//get id param from index.phtml (view)
$id = $this->getRequest()->getParam('club_id');
//get model and query by $id
$clubs = new Application_Model_DbTable_Clubs();
$clubs = $clubs->getClub($id);
//assign data from model to view [EDIT](display.phtml)
$this->view->clubs = $clubs;
$form = new Application_Form_Comment();
$form->submit->setLabel('Comment');
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$comment = new Application_Model_DbTable_Comments();
$comment->addComment($formData['comment'], $id);
$this->_helper->redirector('index');
} else {
$form->populate($formData);
}
}
}
Comment form:
<?php
class Application_Form_Comment extends Zend_Form
{
public function init()
{
$this->setName('comment');
$id = new Zend_Form_Element_Hidden('id');
$id->addFilter('Int');
$comment = new Zend_Form_Element_Text('comment');
$comment->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$this->addElements(array($id, $comment, $submit));
}
}
Comments model:
<?php
class Application_Model_DbTable_Comments extends Zend_Db_Table_Abstract
{
protected $_name = 'comments';
public function getComment($id) {
$id = (int) $id;
$row = $this->fetchRow('id = ' . $id);
if (!$row) {
throw new Exception("Count not find row $id");
}
return $row->toArray();
}
public function addComment($comment, $club_id) {
$data = array(
'comment' => $comment,
'club_id' => $club_id,
'comment_date' => new Zend_Db_Expr('NOW()'),
);
$this->insert($data);
}
public function deleteComment($id) {
$this->delete('id =' . (int) $id);
}
}
ClubDescription Index.phtml:
<div id="comments-holder">
<p id="comments-title">Comments</p>
<?php echo $this->form; ?>
</div>
Thanks
Rik
soap-response: is Content-Length required in http-header?
I didn't found a answer to this in w3.org.
Almost all examples include the content length in the soap-response http-header.
first Q:
But is it technically necessary?
i am struggling with an soap-service where the php-soap-library is setting the right content length of the response xml, but lighttpd afterwards is compressing the content, and so i am getting a smaller response than the content length.
And some applications like soapUI is waiting for alle the content (set by the http-header) to arrive.
second Q:
- Who is behaving/configured wrong in this chain? php -> lighttpd -> soapUI
- is it the php-code
- which sets the unzipped content-length?
- is it lighttpd which compresses the response, but doesn't override or delete the
content-length header? - Or is it soapUI, which shouldn't wait 15sec for further content?
How to check whether a website deployed in IIS 6.1 is being access by user or not?
We have deployed 5 website (read only data) in IIS 6.1 on last month now we want to remove those website which are not acceses/used by used. We have total 10 website on IIS 6.1.
GUI programming in java for Windows?
Can someone tell me what is the best approach for making GUI applications for windows with JAVA ? is it AWT and SWING ? Or is it outdated?
How to check the connection state of a TCP Server (Socket) with TCP Client in VB.NET
For almost a week I am reading and trying to find a solution for checking connection state using a TCP Client (using socket class)
In my scenario I have a TCP Client that is connected to a server (it is not controlled by me) and i want that from time to time to check the connection state, and reconnect if necessary.
I have read a lot of information on the internet but i did not find a suitable solution.
Briefly, these are the methods that i have found on the internet and try to implement.
But unfortunatelly, i have found some scenarios where the TCP Server is closed and the TCP Client is still saying Connected
May i kindly ask someone that have encountered this issue to help me?
1.Example from MSDN
Private Function IsConnected(tcpSocket As Socket) As Boolean
Dim blockingState As Boolean = tcpSocket.Blocking
IsConnected = False
Try
Dim tmp(0) As Byte
tcpSocket.Blocking = False
tcpSocket.Send(tmp, 0, 0)
Return True
Catch e As SocketException
If e.NativeErrorCode.Equals(10035) Then
Return True
Else : Return False
End If
ThrowError(e)
Finally
tcpSocket.Blocking = blockingState
End Try
End Function
2.Example using Poll
Function Connected() As Boolean
Connected = False
If (tcpSocket.Connected) Then
If ((tcpSocket.Poll(0, SelectMode.SelectWrite)) AndAlso (Not tcpSocket.Poll(0, SelectMode.SelectError))) Then
Dim b As Byte() = New Byte(1) {}
If tcpSocket.Receive(b, SocketFlags.Peek) = 0 Then
Return False
Else : Return True
End If
Else
Return False
End If
Else
Return False
End If
End Function
3.Using Poll
Private Function Connect2() As Boolean
Connect2 = False
If tcpSocket.Poll(0, SelectMode.SelectRead) = True Then
Dim byteArray As Byte() = New Byte(1) {}
If (tcpSocket.Receive(byteArray, SocketFlags.Peek)) = 0 Then Connect2 = True
End If
Return Connect2()
End Function
StringTemplate - How to iterate through list of business objects and output simple html?
I've just started using StringTemplate in my C# project. I went through the documentation, but I can't seem to find a way to implement this simple scenario:
I have a list of simple business objects (let's say Orders) and I want them displayed inside a UL tag inside my html template.
So, my .st template looks like this (pseudo-code):
<html> some text <ul>[Order template]<li>[Order name here]</li>[/Order template]</ul></html>
and I want my output to be:
<html> some text <ul><li>Order 1</li><li>Order 2</li>...</ul></html>
I can't figure out how to make this work using StringTemplate. Any ideas?
what is bucket pointer in c++?
What is the difference between a pointer and bucket pointer? What is bucket pointer in C/C++? What are the advantages and drawbacks of using them? Could someone provide some insight into it?
Thanks,
Ravi
Is it possible to specify a list length on an anonymous type?
I am converting an older data set to schema/xml. It contains a few elements that are arrays with default values. I am close to a solution with xs:list;
<xs:element name="pressure"
default="0.22 0.33 0.44 0.55 0.66 0.77 0.88 0.88 0.88 0.88">
<xs:simpleType>
<xs:list>
<xs:simpleType>
<xs:restriction base="xs:float">
<xs:minInclusive value="0.0" />
<xs:maxInclusive value="2.0" />
</xs:restriction>
</xs:simpleType>
</xs:list>
</xs:simpleType>
</xs:element>
How can i limit the length of the list to 10? I.e., where in this would I put the
<xs:length value="10">?
Trying to display a variable created in one jpanel and display it in another jpanel
I'm a student programming a frogger game, when the frog collides with an object or reaches the end zone either the score is incremented or lives decremented and the frog returned to the start position. this section works and the decrement and increment work when outputting them to the console, I try to pass the variable to the other jpanel and display it there but it doesnt update and display the variable in the textField.
Game Panel
public GamePanel() {
super();
setFocusable(true);
addKeyListener(new KeyList());
System.out.println("GAME PANE FOCUS:" + this.isFocusOwner());
scores.setVisible(true);
lives = p.STARTLIVES;
scores.setCurrentLives(lives);
txtTest.setText("Hello");
txtTest.setVisible(true);
add(scores,new AbsoluteConstraints(0,550,50,800));
Boolean displayable = scores.isDisplayable();
System.out.println("Displayable" + displayable);
scores.setEnabled(false);
scores.revalidate();
scores.repaint();
scores.setVisible(true);
System.out.println("Displayable" + displayable);
car1.start();
car2.start();
car3.start();
car4.start();
Log1.start();
Log2.start();
Log3.start();
Log4.start();
Log5.start();
Log6.start();
Log7.start();
Log8.start();
//check for collisions
}
final public void winZone(Rectangle object){
if(myFrog.frogArea().intersects(object)){
currentScore = currentScore + 100;
System.out.println("current Score " + currentScore);
p.setScore(currentScore);
scores.myScore().setText("hello");
myFrog.lostLife();
}
scores panel
public class jplScores extends JPanel {
Properties p = new Properties();
int currentLives;
int i;
/** Creates new form jplScores */
public jplScores() {
initComponents();
}
public void setCurrentLives(int Lives){
currentLives = Lives;
}
public String getCurrentLives(){
String L = Integer.toString(currentLives);
return L;
}
public JTextField myScore(){
return txtScore;
}
Currently it will display the jpanel from the frame that they are both in but i have tried to make it so its a panel within a panel but i cant get the panel to display from within the game panel.
Any help would be great thanks
public FroggerGame() {
initComponents();
setFocusable(true);
//repaint();
// p.setHeight(550);
// p.setWidth(800);
// p.setLives(3);
// p.setScore(0);
PANELHEIGHT = p.getHeight();
PANELWIDTH = p.getWidth();
welcomePanel();
/*
Toolkit tool = Toolkit.getDefaultToolkit();
imgBackground = tool.getImage(imageBackground);
background = new ImageIcon(imgBackground);
//setDefaultCloseOperation(EXIT_ON_CLOSE);
*/
jps.myScore().addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent evt) {
// txtScorePropertyChange(evt);
jps.myScore().setText(Integer.toString(gp.currentScore()));
System.out.println(Integer.toString(gp.currentScore()));
jps.getScore(gp.currentScore());
System.out.println(" main score " + gp.currentScore());
}
});
}
....
private void btnEnterActionPerformed(ActionEvent evt) {
welcomePanel.setVisible(false);
getContentPane().setLayout(new AbsoluteLayout());
getContentPane().add(gp,new AbsoluteConstraints(0,0,800,550));
getContentPane().add(jps,new AbsoluteConstraints(0,550,800,100));
//gp.setSize(800, 550);
// gp.setBounds(0, 0, 800, 550);
gp.setVisible(true);
gp.requestFocusInWindow();
jps.setVisible(true);
gp is the game panel and jps is the score panel.
Overriding the paint method in JTextField to draw text
I am wishing to draw a number onto a JTextField
by overwriting the paint method. So that when the user edits the text field the number doesn't disappear. However, at the moment, the number isn't appearing at all, I have tried:
public void paintComponent(Graphics g) {
super.paintComponent(g);
if(number != 0){
g.setColor(Color.RED);
g.drawString(String.valueOf(number),0,0);
}
}
Any ideas, is this even possible?
How to use/deploy Logger from Log4J with remote jboss container?
I'm checking out the tutorial http://arquillian.org/guides/getting_started/. Everything runs fine. But if I try to add Logger from Log4J with a log4j.xml (placed in src/main/resources) only the embedded containers weld and glassfish runs fine with console log-appender. On the console I got my message:
2012-04-23T15:27:21,859 INFO call greet (de.sealsystems.ejbtest.Greeter)
The remote jboss fails.
My deployment:
@Deployment
public static JavaArchive createDeployment()
{
final JavaArchive deployment = ShrinkWrap.create(JavaArchive.class)
.addClasses(Greeter.class, PhraseBuilder.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml").addAsResource("log4j.xml");
return deployment;
}
The stacktrace-snippet:
15:33:11,375 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC0000
1: Failed to start service jboss.deployment.unit."a680b2b8-2dd6-4b0b-bc87-9082f2
4fc88d.jar".WeldService: org.jboss.msc.service.StartException in service jboss.d
eployment.unit."a680b2b8-2dd6-4b0b-bc87-9082f24fc88d.jar".WeldService: org.jboss
.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for t
ype [Greeter] with qualifiers [@Default] at injection point [[field]
I also tried with adding Logger.class to the JavaArchive, but that also fails with the following stacktrace-snippet:
15:36:50,031 WARN [org.jboss.modules] (MSC service thread 1-3) Failed to define
class org.apache.log4j.Logger in Module "deployment.eb8033fe-29d7-4fa5-986f-303
4a1949020.jar:main" from Service Module Loader: java.lang.LinkageError: Failed t
o link org/apache/log4j/Logger (Module "deployment.eb8033fe-29d7-4fa5-986f-3034a
1949020.jar:main" from Service Module Loader)
What is my mistake?
How to write the path to an html file in a javascript function
I want to load a HTML file in an Iframe dynamically.
I tried the following code:
<script type="text/javascript">
$(document).ready(function () {
$('a').click(function (e) {
e.preventDefault();
filename = "E:\\SVN_HobbyHomes\\HobbyHomesWebApp\\Models\\"+ $(this).text()+".html";
alert(filename);
$('iframe').attr('src', filename);
});
}); </script>
It doesn't load the file in the path inside the Iframe.
PUT handler not found with serviceStack on IIS7.5
I am currently using serviceStack for creating REST based services which are hosted in a MVC web application.
So far ServiceStack has been amazing and I have achieved to get most of what I wanted to do working. All this works in IISExpress.
I have now moved over to IIS 7.5 and I get the 400 error that the PUT handler does not exist.
On IISExpress this all worked.
Any ideas?
gnuplot, draw only the legend and not the graph plot
I have an interactive perl script which uses data from mysql to generate many plots through the Chart::Gnuplot package. There are times when the graph size is overloaded with too many plots.
I would option to generate the gnuplot image containing only the legend (no graph).
How do you find a min / max with Ruby?
I want to do something simple and straightforward, like min(5,10)
, or Math.max(4,7)
. Are there functions to this effect in Ruby?
AJAX posting to CakePHP controller action
I am posting some form values used for registration into a cakePHP controller action. The code is like this
var params='firstname='+encodeURIComponent(firstname) +'&lastname='+encodeURIComponent(lastname)+'&emailid='+encodeURIComponent(emailid)+'&password='+encodeURIComponent(password);
xmlhttp.open('POST', url, true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(params);
this is doing the posting and I can see it in the Firebug in the POST section source as
firstname=name&lastname=name&emailid=mymailid&password=123123
But when I print $this->data in the action , it is not not showing any values. I have even used $_POST and it is also returning anything..
What I done wrong here..?
from object in Tuple[of Sets()]: - is giving me the whole Tuple back instead of just one Set
I'm starting to write an AI for a uni portfolio in Python.
The AI is for a game called Planet Wars, which is a clone of GalCon (Galactic Confusion).
It's in it's basic stage thus far. My goal is to write an AI which loosely follows Sun Tzu's the Art of War, as I interpret it for the game.
I'm kludging through, learning as I go, but for the life of me I can't figure out why line 92 gives me the whole of self._currentTactics instead of just one tactic at a time...
I'd love it if the lovely people around here could help me out.
Just the AI File:
The whole game's code(requires pygame):
https://www.dropbox.com/sh/mma5qwd2iv0i81d/mpemB7zlhT
JQuery fixed sidebar not working on long content
I have a wordpress website where in post page I have a jquery fixed sidebar. The fixed sidebar starts from the post section and stops at comment section.
I am using this jquery
$window = $(window),
$sidebar = $("#side-scroller"),
sidebarTop = $sidebar.position().top,
sidebarHeight = $sidebar.height(),
$footer = $("#comments"),
footerTop = $footer.position().top,
$sidebar.addClass('fixed');
function isScrolledIntoView(elem)
{
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elemTop = $(elem).offset().top;
var elemBottom = elemTop + $(elem).height();
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
$window.scroll(function(event) {
scrollTop = $window.scrollTop(),
topPosition = Math.max(0, sidebarTop - scrollTop),
topPosition = Math.min(topPosition, (footerTop - scrollTop) - sidebarHeight);
$sidebar.css('top', topPosition);
if(isScrolledIntoView('#comments')){
$("#side-scroller").hide();
}
else{
$("#side-scroller").show();
}
});
This works well, but when the post content is too long then it never stops at the comment section.
Here you can see the demo,
Normal post(where fixed sidebar works properly)
http://webstutorial.com/html5-css3-toggle-slideup-slidedown/html-5
And long post(where sidebar keeps on scrolling)
http://webstutorial.com/google-server-side-geocoding-php-infobox/website-tweaks/google
THIS IS NOT SPAM, OR LINK BUILDING, so please no down votes
Is this a better way to fire/invoke events without a null check in C#?
Most code I have seen uses the following way to declare and invoke event firing:
public class MyExample
{
public event Action MyEvent; // could also be a event EventHandler<EventArgs>
private void OnMyEvent()
{
var handler = this.MyEvent; // copy before access (to aviod race cond.)
if (handler != null)
{
handler();
}
}
public void DoSomeThingsAndFireEvent()
{
// ... doing some things here
OnMyEvent();
}
}
Even ReSharper generates an invoking method the way mentioned above.
Why not just do it this way:
public class MyExample
{
public event Action MyEvent = delegate {}; // init here, so it's never null
public void DoSomeThingsAndFireEvent()
{
// ... doing some things here
OnMyEvent(); // save to call directly because this can't be null
}
}
Can anyone explain a reason why not to do this? (pro vs. cons)
Textboxes not populating with multiple comboboxes
I have three comboboxes and three columns of textboxes. For some reason only the first combobox I make a selection in is the only one that will populate the appropriate textboxes. I can make any of the three comboboxes my first choice but the only one that will fill its appropriate textboxes is the first one I choose. Here is the code that populates the textboxes. They are exactly the same so I'm not really sure why I'm having this issue. Any help is appreciated.
Well, here's the SelectedIndexChanged for each combobox. I'm not sure that is where the problem is though
private void cboClientsTab3_SelectedIndexChanged(object sender, EventArgs e)
{
CustomerAccount custAccount = account[cboClientsTab3.SelectedIndex] as CustomerAccount;
if (custAccount !=null)
{
txtAccountNumberTab3.Text = custAccount.GetAccountNumber();
txtCustomerNameTab3.Text = custAccount.GetCustomerName();
txtCustomerAddressTab3.Text = custAccount.GetCustomerAddress();
txtCustomerPhoneNumberTab3.Text = custAccount.GetCustomerPhoneNo();
}
}
private void cboStocksTab3_SelectedIndexChanged(object sender, EventArgs e)
{
Stock aStock = account[cboStocksTab3.SelectedIndex] as Stock;
if (aStock != null)
{
txtStockIDTab3.Text = aStock.GetInvestmentID();
txtStockNameTab3.Text = aStock.GetInvestmentName();
txtStockSymbolTab3.Text = aStock.GetInvestmentSymbol();
txtStockSharesTab3.Text = aStock.GetInvestmentShare().ToString();
txtStockPriceTab3.Text = aStock.GetStockPrice().ToString();
}
}
private void cboMutualFundsTab3_SelectedIndexChanged(object sender, EventArgs e)
{
MutualFund aMutualFund = account[cboMutualFundsTab3.SelectedIndex] as MutualFund;
if (aMutualFund!=null)
{
txtMutualIDTab3.Text=aMutualFund.GetInvestmentID();
txtMutualNameTab3.Text=aMutualFund.GetInvestmentName();
txtMutualSymbolTab3.Text=aMutualFund.GetInvestmentSymbol();
txtMutualSharesTab3.Text=aMutualFund.GetInvestmentShare().ToString();
txtNAVTab3.Text=aMutualFund.GetNAV().ToString();
}
}
Javamail changing charset of subject line
I am using Javamail (javax.mail) to send mails. I successfully adjusted contents of my mail as utf-8. However I could not set subject line as a utf-8 encoded string.
I tried even
mail.setSubject(new String(subject.getBytes("utf-8"), "utf-8"));
on subject however it still sends as Cp1252. Example headers from mail are given below:
Any ideas?
How to open address book on button click? [closed]
By clicking on the button, the addresbook has to open and editing, adding and deleting contacts has to take place.
HOw can I access two database in single .edmx file?
I have created mvc3 application.
I have one .edmx
already created which is based on Db1
but now
I have created a view which is based on Database2
and I need to use this view inside my project.
For that I need to update my EF .edmx
file.
but when I right click and select option Update model from Database
i'm only getting all tables , view ,sps from
Db1` its obvious
Database2
But as i need to use view which is fromhow can i add it into my model
.edmx` file?
please help.
WebBrowser component not showing CSS 3
I am building a piece of software that requires a WebBrowser component.
Unfortunatly it wont show my page right.
my content uses this CSS style:
.content_mid{
background-image:url(http://img.awesome-o.net/Content_Mid.png);
background-size: 100% 100%;
vertical-align:text-top;
padding-left: 40px;
padding-right:20px;
min-height:400px;
}
Since i already found out the WebBrowser component uses the installed version of interwebs explorer i checked the html on internet explorer, and it shows perfectly.
Here you see what it shows on IE:http://i.stack.imgur.com/rMrue.jpg
And here is how it displays on the webbrowser component:http://i.stack.imgur.com/gADsG.jpg
So.. i checked the browser version:
Debug.WriteLine("WebBrowser version: " + webBrowser1.Version);
output: WebBrowser version: 9.0.8112.16443
So that should be alright i guess,
butterworth low-pass filter for android
I'm currently involved in attempting to make a crude pedometer.
It has come to the stage where i am reading in signals and plotting them on Excel to analyse...
The data is quite noisy due to step bounce back and various other reasons. I am taking in a single acceleration vector and was trying to use the following DSP filter design tool that i found through the york cs department to design a Butterworth low-pass filter:
http://www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html
It may be that I am inputting the wrong values for the necessary fields but at the same time I am having trouble translating the Ansi "C" code to Java!
Would anyone be able to lend a helping hand?
ruby: websocket server and websocket client can't work
I am a really newbie for this.but, I can't figure out what's wrong with this problem.
I just copied from somewhere online about a ruby websocket server and a ruby websocket client implementation. I had also installed ruby 1.93 on my windows xp. all looked fine but the websocket client doesn't really work well.
server side code:
equire 'em-websocket'
EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080) do |ws|
ws.onopen { ws.send "Hello Client!"}
ws.onmessage { |msg| ws.send "Pong: #{msg}" }
ws.onclose { puts "WebSocket closed" }
end
Client side code:
require 'eventmachine'
require 'em-http-request'
EventMachine.run {
http = EventMachine::HttpRequest.new("ws://localhost:8080").get :timeout => 0
http.errback { puts "oops" }
http.callback {
puts "WebSocket connected!"
http.send("Hello client")
}
http.stream { |msg|
puts "Recieved: #{msg}"
http.send "Pong: #{msg}"
}
}
the client side always spin out "oops" . that means there's is an error happened.
Could anybody give me any clue for this? I appreciate.
Cannot show the results from the database using a JList
This got to be an easy fix. I have been trying all day yesterday, and I cannot get this thing working.I cannot fetch data from a database and show it in a JList.
// declare global list
private static JList list;
//String[] results;
private DefaultListModel model;
// function that adds components to GridBagConstraints Layout Manager
private void addComponent(JPanel panel, JComponent theComponent, int xPos, int yPos, int compWidth, int compHeight, int place, int stretch, boolean useScrollPane){
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = xPos;
gbc.gridy = yPos;
gbc.gridwidth = compWidth;
gbc.gridheight = compHeight;
gbc.weightx = 100;
gbc.weighty = 100;
gbc.insets = new Insets(2,2,2,2);
gbc.anchor = place;
gbc.fill = stretch;
if(useScrollPane){
JScrollPane scrollPane = new JScrollPane(theComponent);
scrollPane.setPreferredSize(new Dimension(400, 200));
panel.add(scrollPane, gbc);
} else {
panel.add(theComponent, gbc);
}
}
// function that will search for records in the database
private void searchRecord(){
model = new DefaultListModel();
list = new JList(model);
list.setVisibleRowCount(3);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//list.setFixedCellHeight(27);
//list.setFixedCellWidth(130);
try {
model.clear();
Connection connect = null;
Class.forName("com.mysql.jdbc.Driver");
String url = "";
String user = "";
String password ="";
connect = DriverManager.getConnection(url,user,password);
Statement SQLStatement = connect.createStatement();
String select = "SELECT * FROM customerinfo WHERE LastName LIKE '"+ txtSearch.getText().trim() +"%'";
ResultSet rows = SQLStatement.executeQuery(select);
while(rows.next()){
model.addElement(rows.getString("FirstName"));
}
rows.close();
connect.close();
txtSearch.setText("");
} catch (ClassNotFoundException e) {
JOptionPane.showMessageDialog(this, "Where is your Mysql JDBC Driver?");
e.printStackTrace();
} catch (SQLException e){
JOptionPane.showMessageDialog(this, "SQLException: " + e.getMessage());
JOptionPane.showMessageDialog(this, "VendorError: " + e.getErrorCode());
}
}
Here is where I add the JList to thePanel3 and then to the JFrame:
addComponent(thePanel3, list, 0, 1, 3, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, true);
this.add(thePanel3, BorderLayout.SOUTH);
theMainPanel.add(thePanel3, BorderLayout.SOUTH);
Please help...I do not know how to work this!
Read a txt line by line in a batch file
Here is my problem. I have a txt file with 100 different video names (examples):
abc.mpg
def.mpg
ghi.mpg
...
xyz.mpg
I want to process those videos one by one using some commands and put the results into a folder with the same name (without the extension):
command1 abc.mpg
command2 abc.mpg
move results .\abc
My question is how can I perform the above iteration with a for loop within a batch file.
expression in ms access
This expression in search query is not giving any results.
code
and code2
are combo boxes in the search form, CS_Code
is a table column.
[CS_Code]=([Forms]![Search Form]![code] Or
[Forms]![Search Form]![code2]) Or
( [Forms]![Search Form]![code] Is Null Or
[Forms]![Search Form]![code2] Is Null )
I am trying to get entries (search results) from table when CS_code
is equal to code
or code2